Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
grep command
Name: the_apostle21 Date: March 3, 2004 at 16:59:44 Pacific OS: Digital UNIX CPU/Ram: Digital
Comment:
I am only fairly new to unix, so i have a question about grep....
i use the grep command at work to search for particular records. i use the grep command as "grep <criteria> <filename>".
i know it is possible to search for two criterias in the one command, but am unsure how to do it. i need to know how to, for example, search for criteria A AND criteria B in the one file in the one one command.
can someone please explain to me how i can do this.
Name: aigles Date: March 4, 2004 at 00:44:07 Pacific
Reply:
If you want to select records which satisfies the criteria A OR B :
grep 'criteria A|criteria B' input_file
If you want to select records which satisfies the criteria A AND B :
grep 'criteria A' input_file | grep 'criteria B'
Jean-Pierre.
0
Response Number 2
Name: Dlonra Date: March 4, 2004 at 12:52:53 Pacific
Reply:
" If you want to select records which satisfies the criteria A OR B : grep 'criteria A|criteria B' input_file "
No: grep -E or egrep 'criteria A|criteria B' input_file
"if you want to select records which satisfies the criteria A AND B : grep 'criteria A' input_file | grep 'criteria B' "
No: grep 'criteria B' $(grep -l 'criteria A' input_file)
0
Response Number 3
Name: aigles Date: March 4, 2004 at 23:01:59 Pacific
Reply:
No: grep -E or egrep 'criteria A|criteria B' input_file That's right
No: grep 'criteria B' $(grep -l 'criteria A' input_file) No, your command select records matching 'criteria B' from files which contains a record matching 'criteria B'.
Records matching 'criteria A' are not displayed. Displayed records match 'criteria B', not criteria A AND B.
Summary: Hi Suppose a file F1 conatins following entries ABCD0B ABCD0Bs ABCD0B.ksh I would like to grep the word that contains only '0B' as last 2 charcaters. When I tried grep command : grep '0B' F1 it resu...
Summary: Hi! I have the text : ...HRD 20050905 820 N Final technical 820HRD If I want to remove only the line with "...HRD". Please some one know how and which the command on shell script to remove t...
Summary: Using the KORN SHELL ONLY, is there any way that I can grep for a string in column/field 1 only? For instance in a data file named inventory, i have: black goodyear tire black michelin tire film win...