- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep something AND something
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-28-2004 05:03 AM
01-28-2004 05:03 AM
grep "s" && "oracle"
does not seem to work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:11 AM
01-28-2004 05:11 AM
Re: grep something AND something
Your question isn't quite clear to me. If you are searching for lines that contain both s and oracle, a simple way is
grep "oracle" file|grep "s"
If you are looking for lines that contain either s or oracle or both then
grep -E -i 'oracle|s' file
or
grep -i -e 'oracle' -e 's' file
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:13 AM
01-28-2004 05:13 AM
Re: grep something AND something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:16 AM
01-28-2004 05:16 AM
Re: grep something AND something
$cat data
oracle a fine word
s is a letter
s not there in oracle
ofcourse s is not there in oracle
but o in oracle
$grep oracle data |grep s
s not there in oracle
ofcourse s is not there in oracle
??
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:29 AM
01-28-2004 05:29 AM
Re: grep something AND something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:35 AM
01-28-2004 05:35 AM
Re: grep something AND something
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 05:43 AM
01-28-2004 05:43 AM
Re: grep something AND something
Give me the lines where BOTH "s" and "oracle" appear in the same line.
grep ("s" -a "oracle") file
I can't think of any way to do it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 06:04 AM
01-28-2004 06:04 AM
Re: grep something AND something
you can try:
grep -E ".*text1.*text2|.*text2.*text1" file
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 08:47 AM
01-28-2004 08:47 AM
Re: grep something AND something
The leading '.*' for 'any characters' do not seem to be needed, giving:
grep -E "oracle.*s|s.*oracle"
but normally you grab for a double grep...
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 08:58 AM
01-28-2004 08:58 AM
Re: grep something AND something
grep -i -e 'oracle' -e 's' file
Note -- BOTH THINGS YOU ARE LOOKING FOR *MUST* have the -e in front of it. That screwed me up before I got the hang of it and I think this could be what you are missing. The following command does not work because it's missing the other "-e":
grep -i oracle -e file
(Note, the -i is optional so that it's case-insensitive)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2004 09:29 AM
01-28-2004 09:29 AM
Re: grep something AND something
#cat toddfile
s and oracle
s only
oracle only
Here is my test...
root:/root
# grep s /tmp/toddfile
s and oracle
s only
root:/root
# grep -e s -e oracle /tmp/toddfile
s and oracle
oracle only
s only
root:/root
# grep s |grep oracle /tmp/toddfile
s and oracle
oracle only
root:/root
# grep s /tmp/toddfile |grep oracle
s and oracle
See the last one shows your example of only showing those lines with both s and oracle on them...
Hope this helps.