- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep "abc" but exclude "def" and "ghi" in the file
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
Forums
Discussions
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
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
11-18-2003 09:33 AM
11-18-2003 09:33 AM
grep "abc" but exclude "def" and "ghi" in the file
Can I do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2003 09:49 AM
11-18-2003 09:49 AM
Re: grep "abc" but exclude "def" and "ghi" in the file
grep -e 'abc' < infile | grep -v -e 'def' -e 'ghi' > outfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2003 05:09 PM
11-18-2003 05:09 PM
Re: grep "abc" but exclude "def" and "ghi" in the file
Use the command
grep "abc" -v "def" "ghi" <
Thanx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2003 05:48 PM
11-18-2003 05:48 PM
Re: grep "abc" but exclude "def" and "ghi" in the file
awk '/def/ {next} /ghi/ {next} /abc/'
should do the trick.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2003 03:21 AM
11-19-2003 03:21 AM
Re: grep "abc" but exclude "def" and "ghi" in the file
Clays´s and Elmar´s work.
Suresh: it doesnt work that way. You cant include and exclude with multiple patterns at the same time.
greetings,
Mich
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2003 03:39 AM
11-19-2003 03:39 AM
Re: grep "abc" but exclude "def" and "ghi" in the file
What is '{next}' in awk, can you please explain it to me?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2003 03:56 AM
11-19-2003 03:56 AM
Re: grep "abc" but exclude "def" and "ghi" in the file
next tells awk to discard this line and start the loop with the next line.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2003 02:57 AM
11-26-2003 02:57 AM
Re: grep "abc" but exclude "def" and "ghi" in the file
if the problem is solved, could you spare some points from the endless supply of points, HP has, for those, who could help you? ;-)
greetings,
Michael