![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating searches? | amatuer_lee_3 | Shell Programming and Scripting | 2 | 05-12-2008 10:04 PM |
| grep multiple lines | cdunavent | Shell Programming and Scripting | 27 | 03-27-2005 04:23 AM |
| grep - multiple positions | nelson553011 | AIX | 3 | 11-16-2004 05:51 AM |
| New Tool Searches and Replaces SCO Code | Neo | News, Links, Events and Announcements | 3 | 08-11-2003 09:37 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
grep: do multiple searches?
I want to search the file /etc/passwd for all lines containing 'csh' but exlude all those lines that have '/usr' in them and dump the results into the file result.
IMPORTANT: I need to do this in one command line. The following does not work: grep -v \(\/usr\) \(csh\) /etc/passwd > result What is the basic thing that I am doing incorrectly here? do I need do first search for all instances of 'csh' and then direct this into another grep for exclude all instances of '/usr' ?? grep -v '/usr' /etc/passwd | grep csh > result regards and thanks, Steve |
| Forum Sponsor | ||
|
|
|
|||
|
Why does this have to be on one command line? This sounds like a homework exercise - and that is not what this forum is for.......(just so you know).
The suggestion you made will work.....have you tried it? grep -v '/usr' /etc/passwd | grep csh > result
__________________
Pete |
|
|||
|
yeah, I did figure this out on my own... that is why I put in the correct answer when I submitted the question.
I wasn't clear as to my real question or state of confusion... I was struck by how simplistic these commands strings must be, and thought I was missing something. When I tried to figure out the answer I just thought that there might be a way to put multiple arguments in one grep command instead passing the output onto another grep command. Many years ago I did BLISS programming and I just have a lot of cobwebs stuck in my brain! |