Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jan 27 '10 at 13:56

This question came from our site for professional and enthusiast programmers.

add comment

4 Answers 4

In bash:

diff listing_server <(ls -1)
share|improve this answer
add comment

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

ls -1 | diff file_goes_here -
share|improve this answer
    
this won't work –  John T Jan 27 '10 at 15:18
    
Now it does. That's what I get for not testing it first. –  Josh K Jan 27 '10 at 16:01
add comment
diff listing <(ls -1)
share|improve this answer
add comment
ls -1 | diff listing_server -
share|improve this answer
    
The -1 is unnecessary if the output is not to a terminal. –  Peter Eisentraut Jan 27 '10 at 16:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.