0

I have the code below (please see Need to understand below awk command to find missing lines in a file):

awk 'NR==FNR{a[$0];next}(!($0 in a)){print}' 1.txt 2.txt

Can I add one more condition to skip the comparison of lines if the line starts with = (i.e '$0 ~ /^=/ {print $0}') and just print those lines alone as it is?

terdon
  • 242,166
dbadmin
  • 23

1 Answers1

2

Yes, this should work:

awk 'NR==FNR{a[$0];next}(!($0 in a) || /^=/){print}' 1.txt 2.txt

The || is an OR statement, so this just adds one more condition to your main if there, checking if the line starts with a =.

terdon
  • 242,166