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

2
  • 1
    Which shell? Some of them support process substitution: diff <(ls | cut -c 1-4) <(ls | cut -c 1-4 | uniq). Commented Aug 14, 2013 at 12:49
  • @manatwork c shell Commented Aug 14, 2013 at 12:53

1 Answer 1

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) 
1
  • 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). Commented Aug 14, 2013 at 13:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.