I have tried the following
nawk 'BEGIN { RS=""; FS="\n"; OFS=","}; /pattern1/ {print $1}' datafile
This prints date for records that have pattern1. But since pattern1 is in different field I don't know how to check for that. I think a for loop to check all the fields upto NF and then use of if...
I have data file with null record separator and end of line as field separator. See below.
Date
pattern2
pattern3
pattern1
Date
pattern1
pattern2
pattern8
Date
pattern5
pattern6
pattern2
Date
pattern1
pattern2
I am only interested in field with pattern1. The problem is field number for...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.