[Solved] How to compare 2 files line by line with terminal


What you are after is an awk script of the following form:

$ awk '(NR==FNR){a[FNR]=$0;next}
       !(FNR in a) { print "file2 has more lines than file1"; exit 1 }
       { print (($0 == a[FNR]) ? "matching" : "not matching") }
       END { if (NR-FNR > FNR) print "file1 has more lines than file2"; exit 1}' file1 file2

solved How to compare 2 files line by line with terminal