I am trying to do something along the lines of:

diff `ls -1a ./dir1` `ls -1a ./dir2`

But that doesn't work for obvious reasons. Is there a better way of achieving this (in 1 line), than this?

ls -1a ./dir1 > lsdir1
ls -1a ./dir2 > lsdir2
diff lsdir1 lsdir2

Thanks

link|improve this question

75% accept rate
feedback

2 Answers

up vote 4 down vote accepted

You were close. In bash you want process substitution, not command substitution:

diff <(ls -1a ./dir1) <(ls -1a ./dir2)
link|improve this answer
+1 and check : Learn something new everyday! – bguiz Jan 4 '11 at 2:52
feedback
diff -rq dir1 dir2

using the -r option, walk entire directory trees, recursively checking differences between subdirectories and files that occur at comparable points in each tree. The trick is to use the -q option to suppress line-by-line comparisons

link|improve this answer
@festo : You wree missing the poitn of this question, I don't actually want to diff the contents of the files, I want to diff the output of the ls commands – bguiz Jan 4 '11 at 2:53
feedback

Your Answer

 
or
required, but never shown

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