Ubuntu 16.04
Bash 4.4.0
sdiff (GNU diffutils) 3.3
When I use the command sdiff in shell formatting is perfect
sdiff -w 185 fileone filetwo
When I use the command sdiff and send the results to a file, formatting disappears
sdiff -w 185 fileone filetwo > filethree
How can I preserve formatting when I send sdiff output to a file?
sdiff -w 185 fileone filetwo -o output
works?sdiff
's-t
option to expand tabs to spaces. Alternatively, tell your viewer/editor to set tab stops to 8 spaces - e.g. in vi:set ts=8
or with less, useless -x8
.sdiff -t -w 185 fileone filetwo > filethree
. When a windows webadmin opened the file, it went back to being unformatted. I added an extra commandexpand -t 2 filethree | sponge filethree
and now the file is perfectly formatted. Hats off to you mate.-t
should have worked for any viewer, it does exactly whatexpand
does. If you want tabstops every 2 spaces, you can use-t --tabsize 2
with sdiff, no need for expand and sponge.