- 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
Discussions
Discussions
Forums
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
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
тАО06-10-2004 12:48 AM
тАО06-10-2004 12:48 AM
Re: grep command
OK, "grep -x" works !
but the reel file is :
156.152.45.5 toto
156.152.45.58 titi
156.152.45.589 bubu
And that i want is only the field "toto"
of the file when $ADRESSIP=156.152.45.5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2004 12:52 AM
тАО06-10-2004 12:52 AM
Re: grep command
grep "156.152.45.5 toto" file
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2004 01:03 AM
тАО06-10-2004 01:03 AM
Re: grep command
This is en example.
I search a comment by the variable $ADRESSIP.
This is not so easy...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2004 05:22 AM
тАО06-10-2004 05:22 AM
Re: grep command
if the name "toto" or whatever is the second field, you can do:
awk '/'$ADRESSIP' / {print $2}' file
This prints only the second field if the first one matches $ADRESSIP. Be carefully with the space after '/'$ADRESSIP' /
^ this one
Hope this helps.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2004 05:24 AM
тАО06-10-2004 05:24 AM
Re: grep command
Sorry but the space is not clear enought in the previus message,
awk '/'$ADRESSIP'
I think this is "more" clear.
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2004 06:05 AM
тАО06-10-2004 06:05 AM
Re: grep command
Without gnu grep, you can do it as follows.
grep "156.152.45.5" ./file|awk -F " " '{if(length($1)==12)print}'
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-10-2004 06:29 AM
тАО06-10-2004 06:29 AM
Re: grep command
awk -v var=$ADRESSIP '
$1 == var {print $2;}' yourFile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2004 10:14 PM
тАО06-18-2004 10:14 PM
Re: grep command
We can use ^ and $ to notify the begin and end of string. It is easy to get the exact string.
ADRESSIP=156.152.45.5
grep ^${ADRESSIP}$
Regards,
Muthukumar
- « Previous
- Next »