To distinguish the first k lines of two files:
$ diff <(head -k file1) <(head -k file2)
Similary to distinguish the last k lines:
$ diff <(tail -k file1) <(tail -k file2)
To distinguish strings from i to j:
diff <(sed -n 'i,jp' file1) <(sed -n 'i,jp' file2)
source
share