Posted March 1, 201410 yr Hi, probably this is too easy but i just started playing around with awk and can't figure this out. Say I have a file with these two lines each split in columns: A S D M A R W D I want awk to print "right answer" if for example the third element in the first line matches the fourth element in the second line, as is the case for letter "D". My attempt was: awk '(NR == 1 && $3 == /D/) && (NR == 2 && $4 == /D/) {print "right answer"}' file.txt But it is not working. Any suggestions? Thanks! Continue reading...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.