6

I have one file that contains a list of files from a server, and a local folder that I compare to that manifest. Obviously, I do 'ls -1 > listing_local' and then diff that file with listing_server.

But is it possible to diff the manifest and the output of ls immediately to the diff command?

4 Answers 4

4

In bash:

diff listing_server <(ls -1)
3

You can pipe the output of a unix command into the input of another.

ls -1 | diff file_goes_here -
2
  • this won't work
    – user1931
    Jan 27, 2010 at 15:18
  • Now it does. That's what I get for not testing it first.
    – Josh K
    Jan 27, 2010 at 16:01
2
diff listing <(ls -1)
1
ls -1 | diff listing_server -
1
  • The -1 is unnecessary if the output is not to a terminal. Jan 27, 2010 at 16:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .