linux - Search A Variable in Specific Column in BASH with awk -
i have log_file below:
log|server301|2015|05|12|00|58|35|572617|0|comp|002.01.003.00|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|002.01.003.00|amsn.cpp|12577|callback:ohmoam::ohmsn2viewchange, old flipbypassonmt log|server302|2015|05|12|00|58|35|593116|0|comp|002.01.003.00|amsn.cpp|12590|callback:ohmoam::ohmsn4viewchange, new flipbypassonmt log|server301|2015|05|12|00|58|35|593302|0|comp|002.01.003.00|amsn.cpp|12577|callback:ohmoam::ohmsn3viewchange, old disableflipbypassonmt log|client1|2015|05|12|00|58|35|593324|0|comp|002.01.003.00|amsn.cpp|12590|callback:ohmoam::ohmsn2viewchange, new disableflipbypassonmt
i want print line no have
word
server
@ 2nd columnword
callback
@ 15th columnvariable
$parameter_name
@ 15th column
i executed below command:
parameter_name="flipbypassonmt" $(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 line no. using sun4-solaris. please me out. n.b:
$(awk -v var="$parameter_name" -f'|' '$2 ~ /server/ && $15 ~ /callback/ { print nr}' $log_file 2>/dev/null | tail -1)
is running fine. need 3 criteria.
have tried
$(awk -v var="$parameter_name" -f'|' '$2 ~ /server/ && $15 ~ /callback/ && $15 ~ var { print nr}' $log_file 2>/dev/null | tail -1)
i'm not sure why used index function when can use ~
regex operator again.
Comments
Post a Comment