How to display line numbers in side by side diff in unix? How to display line numbers in side by side diff in unix? unix unix

How to display line numbers in side by side diff in unix?


Below code can be used display uncommon fields in two files, side by side.

sdiff -l file1 file2 | cat -n | grep -v -e '($'  

Below code will display common fields along with line numbers in the output.

diff -y file1 file2 | cat -n | grep -v -e '($'  


sdiff -s <(cat -n file1.txt) <(cat -n file2.txt)

This gives you side-by-side output with line-numbers from the source files.


The following command will display the side-by-side output prepended with line numbers for file1.txt and identical lines removed.

sdiff -l file1.txt file2.txt | cat -n | grep -v -e '($'