0

I have two files, baseline.txt and result.txt. I need to be able to find if lines in baseline.txt are also in results.txt. For example, if lines 8-12, is in results.txt. I need to use awk. Thanks.

user2719735
  • 97
  • 2
  • 10

1 Answers1

0

Assuming the files are sorted, it looks like comm is more of what you're looking for if you want lines that are present in both files:

comm -12 baseline.txt results.txt

The -12 argument suppresses lines that are unique to baseline.txt and results.txt, respectively, leaving you with only lines that are common to both files ("suppress lines unique to file 1, suppress lines unique to file 2").

If you are dead set on using awk, then perhaps this question can help you.

Community
  • 1
  • 1
michaelgulak
  • 631
  • 1
  • 6
  • 14
  • I have to use awk, and I am not trying to look for duplicate lines, I am searching if lines 8-12 of file1 is in file2. I have gotten this much "lines=$(nawk '{ if (NR >= 8 && NR <= 12) print $0}' test/.baseline)", but that only prints out lines 8-12, how can I use awk to search if those lines are in the results.txt. – user2719735 Mar 06 '15 at 03:49
  • Then you should edit your question to be more clear, ie: "How can I use awk to determine if lines in one file of my choosing (lines 8-12, for example) are also present anywhere in another file?" – michaelgulak Mar 06 '15 at 16:12