- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep command ??
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:21 AM
01-29-2003 08:21 AM
grep command ??
ie:
test
test_107
tup_test
etc.....
the grep for tet would return all three entries when I only want the 1st entry returned...
any ways to get around this ??
Thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:25 AM
01-29-2003 08:25 AM
Re: grep command ??
for more involved parsings use Perl (where amongst other things) you can set anchors in form of word boundaries.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:26 AM
01-29-2003 08:26 AM
Re: grep command ??
grep "^test$"
^ = anchor to start of line
$ = anchor to end of line
To get complete word test takes a little more effort.
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:27 AM
01-29-2003 08:27 AM
Re: grep command ??
grep "^test$" file
^ matches beginning of line
$ matches end of line
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:28 AM
01-29-2003 08:28 AM
Re: grep command ??
append a [[:space:]] to you're regex while using egrep or -E switch (which stands for extended grep)
but that said, nothing compares to Perl's regex capabilities
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:29 AM
01-29-2003 08:29 AM
Re: grep command ??
# grep -w test file
GNU grep available on http://www.cmve.net/~merijn or https://www.beepz.com/personal/merijn
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:29 AM
01-29-2003 08:29 AM
Re: grep command ??
Try this:
grep test filename|head -n 1
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:29 AM
01-29-2003 08:29 AM
Re: grep command ??
# grep -E -e " test " -e " test$" -e "^test " -e "^test$"
...would limit the selection to the word "test".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 08:30 AM
01-29-2003 08:30 AM
Re: grep command ??
Try this:
# grep -x test input_file
Hai