![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep help | flood | Shell Programming and Scripting | 3 | 06-06-2008 02:14 AM |
| Grep | Aejaz | UNIX for Advanced & Expert Users | 3 | 04-30-2008 08:10 AM |
| grep | dineshr85 | Shell Programming and Scripting | 1 | 10-10-2007 05:52 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-05-2007 03:59 AM |
| Make grep -c display like grep -n? | Jerrad | Shell Programming and Scripting | 2 | 08-25-2006 01:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help on grep -v
Hi all,
i would like to know if it is possible to pass many string arguments for grep -v. For example from my logs i need to extract all the lines which r not having "string1" and "string2". this string list could be changed in future, so instead of changing the script i define them in a .prop file. Now, instead of doing grep -v string1 a.log | grep -v string2 .... is there any other way to do that ?? tnx |
|
||||
|
tnx Jim,
I got one more question, is there anyway we could do a split a string. my idea is to have string like prevent string1,string2,string3 get these substrings and build the grep command from a loop ... if u have a better idea, would be welcomed... tnx |
|
||||
|
You can use a file that is a grep "script" Here is a file t.sed: Code:
string1 string2 string3 using it in grep Code:
grep -v -f t.sed a.log > newfile You also build your t.sed by searching another file, example: the first five characters of each line in a series of files in /path/to directory: Code:
find /path/to -name '*.log' | \
while read file
do
cut -c -5 "$file"
done | sort -u > t.sed
grep -v -f t.sed /path/to/somewhere/a.log
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|