![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| handling null values in files | ammu | Shell Programming and Scripting | 1 | 11-06-2007 04:43 PM |
| Help!! Need script to read files and add values by lines... | dhuertas | Shell Programming and Scripting | 3 | 09-15-2007 11:14 PM |
| Need to find only unique values for a given tag across the files | sudheshnaiyer | UNIX for Dummies Questions & Answers | 8 | 09-03-2007 12:53 AM |
| grepping lines out of files | mariner | UNIX for Advanced & Expert Users | 2 | 09-24-2004 08:12 AM |
| Extracting values from files | Master Error | Shell Programming and Scripting | 4 | 08-15-2004 09:23 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grepping many values from same files
Hi All,
I am having a script in which I am greping some values and storing them from files with .err and .log extensions. I feel I can do it better.But How? Below is my piece of code. Code:
oneerrors=`egrep -i -n "one" *.err *.log` twoerrors=`egrep -i -n "two" *.err *.log` threeerrors=`egrep -i -n "three" *.err *.log | grep -v "threeException"` fourerrors=`egrep -i -n "four" *.err *.log` fiveerrors=`egrep -i -n "five" *.err *.log | grep -v "fivefile" | grep -v "five:"` sixerrors=`egrep -i -n "six" *.err *.log` sevenerrors=`egrep -i -n "seven" *.err *.log | grep -v "SREE_seven" | grep -v "SRE_seven" | grep -v "VALUE_seven" | grep -v "PRODUCT_seven"` eighterrors=`egrep -i -n "eight" *.err *.log` nineerrors=`egrep -i -n "nine" *.err *.log` tenerrors=`egrep -i -n "ten" *.err *.log` elevenerrors=`egrep -i -n "eleven" *.err *.log` twelveerrors=`egrep -i -n "twelve" *.err *.log` Thanks to All. Last edited by Sreejith_VK; 03-15-2008 at 09:01 AM.. |
|
||||
|
Code:
awk 'BEGIN {
pat="one|two|four|five|six|eight|nine|ten|eleven|twelve"
}
$0 ~ pat || (/three/ && !/threeException/ ) {print NR":"$0}
$0 ~ pat || (/seven/ && !/(SREE_seven|SRE_seven|VALUE_seven|PRODUCT_seven)/) {print NR":"$0}
$0 ~ pat || (/five/ && !/(fivefile|five:)/) {print NR":"$0}
' file
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|