- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk command question: equivalent to grep.?
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
05-25-2007 08:43 AM
05-25-2007 08:43 AM
What is the awk command that is equivalent to "grep -i -e "
Example:
# swlist -l product | grep -i -e "serviceguard" -e "PHSS_34504"
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2007 08:49 AM
05-25-2007 08:49 AM
Re: awk command question: equivalent to grep.?
# swlist -l product | awk '$1=="ServiceGuard" || $1=="PHSS_34504"'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2007 08:52 AM
05-25-2007 08:52 AM
Re: awk command question: equivalent to grep.?
The only thing I see in awk is that you can use tolower and then do the compare or regular expression match. To search for multiple patterns (-e), you would have to use ||.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2007 10:08 AM
05-25-2007 10:08 AM
Re: awk command question: equivalent to grep.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2007 03:24 PM
05-25-2007 03:24 PM
Re: awk command question: equivalent to grep.?
Sandman: command working, you already using the correct string. :)
Ivan,
Looks like in your command IGNORECASE not working: Any way I got the idea.
# swlist -l product | awk -v IGNORECASE=1 '/serviceguard|PHSS_34504/ { print $0}'
PHSS_34504 1.0 Serviceguard A.11.16.00
# swlist -l product | awk -v IGNORECASE=1 '/ServiceGuard|PHSS_34504/ { print $0}'
PHSS_34504 1.0 Serviceguard A.11.16.00
ServiceGuard A.11.16.00 ServiceGuard
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 07:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 07:56 AM
05-29-2007 07:56 AM
Re: awk command question: equivalent to grep.?
hpap091# swlist -l product | gawk -v IGNORECASE=1 '/serviceguard|PHSS_34504/ { print $0}'
PHSS_34504 1.0 Serviceguard A.11.16.00
SG-Apache-Tool B.02.21 Serviceguard Apache Script Templates
SG-NFS-Tool A.11.23.03 Serviceguard NFS Script Templates
SG-Oracle-Tool B.02.21 Serviceguard Oracle Script Templates
SG-Samba-Tool B.02.21 Serviceguard Samba Script Templates
SG-Tomcat-Tool B.02.21 Serviceguard Tomcat Script Templates
ServiceGuard A.11.16.00 ServiceGuard
hpap091#
Thanks for pointing out that, and it works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 08:20 AM
05-29-2007 08:20 AM
Re: awk command question: equivalent to grep.?
# swlist -l product ServiceGuard -l product PHSS_34504
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 07:09 PM
05-29-2007 07:09 PM
Re: awk command question: equivalent to grep.?
If you are still looking the awk option, here it is:
# swlist -l product | awk ' { tolower($1) } /DigitalVideo|PHKL_8377/'
DigitalVideo B.10.20 Digital Video Software
PHKL_8377 B.10.00.00.AA vmtrace and malloc() patch
The above is from an old machine, I have. For your case it is like:
swlist -l product | awk ' { tolower($1) } /ServiceGuard|PHSS_9397/'
Regards,
Rasheed Tamton.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 07:18 PM
05-29-2007 07:18 PM
Re: awk command question: equivalent to grep.?
This doesn't really work. The result of tolower isn't used. The regular expression you have, matches without any need to downshift.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 07:27 PM
05-29-2007 07:27 PM
Re: awk command question: equivalent to grep.?
$ swlist -l product | awk 'toupper($1) ~ /MAKE|GETTEXT/'
This returns:
automake 1.9.6 automake
make 3.80 make
Gettext 0.10.39.4 GNU gettext NLS library
gettext 0.12 gettext
(Your patterns must be the case of your "to*" function.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2007 09:15 PM
05-29-2007 09:15 PM
Re: awk command question: equivalent to grep.?
DigitalVideo B.10.20 Digital Video Software
X11 B.10.20 HP-UX X Window Software
X11BMS B.10.20 HP-UX BMS for X Window Software
openssh 4.3p2 openssh
The only thing to take care is that the regex should be in lower case.
So, in this case need to use /(serviceguard|phss_9397)/
both search strings should be in lower case becuase it is already converted to lower case.