How do I diff the outputs of two commands?
Use process substitution:
diff <(cat /etc/passwd) <(cut -f2 /etc/passwd)
<(...)
is called process substitution. It converts the output of a command into a file-like object that diff
can read from.
While process substitution is not POSIX, it is supported by bash, ksh, and zsh.
Difference between 2 commands output :-
$ diff <(command1) <(command2)
Difference between command output and file :-
$ diff <(command) filename
Difference between 2 files :-
$ diff file1 file2
e.g. $ diff <(mount) <(cat /proc/mounts)