Search A Variable in Specific Column in BASH with awk

I have LOG_FILE like below:

LOG|Server301|2015|05|12|00|58|35|572617|0|COMP||DSOHMSN2ViewCallback.cpp|142|CALLBACK:DSOHMSN2ViewCallback::FLIPBypassOn Changed SN=2 old value =2 new value =1
LOG|Client2|2015|05|12|00|58|35|593088|0|COMP||AMSN.cpp|12577|CALLBACK:OHMOAM::ohmSN2ViewChange, Old FLIPBypassOnMT
LOG|Server302|2015|05|12|00|58|35|593116|0|COMP||AMSN.cpp|12590|CALLBACK:OHMOAM::ohmSN4ViewChange, New FLIPBypassOnMT
LOG|Server301|2015|05|12|00|58|35|593302|0|COMP||AMSN.cpp|12577|CALLBACK:OHMOAM::ohmSN3ViewChange, Old disableFLIPBypassOnMT
LOG|Client1|2015|05|12|00|58|35|593324|0|COMP||AMSN.cpp|12590|CALLBACK:OHMOAM::ohmSN2ViewChange, New disableFLIPBypassOnMT

I just want to print line no which have

  • word Server at 2nd column

  • word CALLBACK at 15th column

  • variable $parameter_name at 15th column

I executed the below command:

$(awk -v var="$parameter_name" -F'|' '$2 ~ /Server/ && $15 ~ /CALLBACK/  && index($15,var) { print NR}' $LOG_FILE 2>/dev/null | tail -1)

But Not getting the line no.
I am using sun4-solaris.
please help me out.

$(awk -v var="$parameter_name" -F'|' '$2 ~ /Server/ && $15 ~ /CALLBACK/ { print NR}' $LOG_FILE 2>/dev/null | tail -1) 

is running fine.
but need all the three criteria.

Source: bash

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.