You can use diff -T or –initial-tab options to make tabs line up by prepending a tab.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
## Prepend a tab in every line of diff output echo -e "1\t2\n3\n4" > myfile1 ## create some files echo -e "1 2\n5\n4" > myfile2 diff -t myfile1 myfile2 ## expands tab in space ## returns ## 1,2c1,2 ## < 1 2 ## < 3 ## --- ## > 1 2 ## > 5 diff -T myfile1 myfile2 ## prepends tab to everyline ## returns ## 1,2c1,2 ## < 1 2 ## < 3 ## --- ## > 1 2 ## > 5 diff myfile1 myfile2 ## normal output ## returns ## 1,2c1,2 ## < 1 2 ## < 3 ## --- ## > 1 2 ## > 5 |