How can I use the
diff command to compare 2 commands' outputs?
Does something like this exist?
diff ($cat /etc/passwd) ($cut -f2/etc/passwd)
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.