Hi friends,
I have small query with reg to awk search pattern..
below is my sample file and code which i tried..
$ cat file.txt
xxx,yyyyy,messageID,sha
xxxx,errorcode,messageID,name
in the above sample file - let assume I know the errorcode(2nd record) using which I want to find out sha record(1st line last column), the key is messageID which would be common for both the record.
I have tried following awk syntax but failing
nawk -F"," '{if($0~/errorcode/) {var=$3;if($0~/var/ && $0!~/errorcode/) print $NF}}' file.txt
Thanks
SHa
---------- Post updated at 03:51 AM ---------- Previous update was at 03:47 AM ----------
Just to add above statement for better understanding...the record which I am searching in above syntax can be anywhere not always one line above or below...thats y i have not tried getline etc....
Thanks
Sha