1

I want to check the difference of two file list

one is ls | cut -c 1-4 another is ls | cut -c 1-4 | uniq

does there exists any way can let me do like this diff (ls | cut -c 1-4) (ls | cut -c 1-4 | uniq) or anyway can let me without saving the two list command into files then check the difference of it ..

thanks

1 Answers1

1

This should work (tested on Linux, from bash)

diff <(ls | cut -c 1-4) <(ls | cut -c 1-4 | uniq)

or in general, lets have two commands cmd1 and cmd2 which produces some output

diff <(cmd1) <(cmd2)
dsmsk80
  • 3,068
  • That works with ksh93 (where process substitution originated), zsh and bash on systems that support /dev/fd/n (or for some shell versions, named pipes). – Stéphane Chazelas Aug 14 '13 at 13:46