The
diff
(
28.1
)
utility adds extra characters (
>
,
<
,
+
, and so on)
to the beginning of lines.
That can cause you real grief with tabstops because the extra characters
diff
adds can shift lines enough to make the indentation look wrong.
The
diff -t
option expands TABs to 8-character tabstops and
solves the problem.
If you use
non-standard tabstops,
though, piping
diff
's output through
expand
or
pr -e
(see article
41.4
):
%
diff afile bfile | expand -4
doesn't help because
diff
has already added the extra characters.
The best answers I've seen are the
bash
<()
process substitution operator and the
!
(exclamation point) script . (
9.18
)
You can expand TABs before
diff
sees them.
For example, to show the differences between two files with 4-column
tabstops:
bash$
diff <(expand -4 afile) <(expand -4 bfile)
bash
%
diff `! expand -4 afile` `! expand -4 bfile`
other shells