linux - AWK if condition matching a string -


i have following awk command. i'm trying find error , print first line error. if error has matching string, i'm trying add in count , later print result in end statement.

how use if condition requirements have below statement, plus print number of occurrences of error?

awk '/^someerror[0-9]+/ {for(i=0;i<=3;i++){getline;if(i==0 && $1 ~ /pattern_to_find/ ){print;count++;}}} end {print count;}' somelogfile.log.2015-07-06 | less 

today print nothing if use if condition following regular expression. if remove command including end statement, prints results, i'd use condition counting purpose , print well.

$1 ~ /pattern_to_find/ 

if have spaces in pattern find, use $0 instead. $0 ~ /pattern find/


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -