I prefer not to create new files. I want to accomplish something similar to:
cmd1 > a
cmd2 > b
cat a b b | sort | uniq -u
but without using files a and b.
If you want to compare two files and decipher the difference, a command called “diff” is used. This guide is focused on providing you the usage of the “diff” command with various options to get the difference between two files. So, how does the “diff” command actually function?
cmp command in Linux/UNIX is used to compare the two files byte by byte and helps you to find out whether the two files are identical or not.
Unix utilities are generally file oriented, so nothing quite does what you want.
However, zsh can autocreate temporary files with the following syntax:
diff =(cmd1) =(cmd2)
It can also create temporary named pipes (or use the special files /dev/fdn
to reference anonymous pipes) with
diff <(cmd1) <(cmd2)
However, many diff
s call lseek()
on their input, so won't work with named pipes.
(diff
is in general a more useful command for comparing very similar output than your pipeline above.)
See the "process substitution" section of the "zshexpn" man page for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With