Compare two directory trees.

diff <(cd dir1 && find | sort) <(cd dir2 && find | sort)
This uses Bash's "process substitution" feature to compare (using diff) the output of two different process pipelines.

35
By: mbirk
2009-05-21 04:44:29

2 Alternatives + Submit Alt

What Others Think

Very nice! Thanks!
DaveQB · 647 weeks and 5 days ago
Hi, take a look to diff man page : diff -a -q -r dir1 dir2
sputnick · 646 weeks ago
My command only compares the file file *names* -- not the contents of the file (like your "diff" command does).
mbirk · 622 weeks and 4 days ago
Very nice, thanks. Here's a possible improvement (shorter to type): diff <(find dir1 | sort) <(find dir2 | sort)
dserodio · 471 weeks ago
Nevermind, my "improvement" is broken :)
dserodio · 471 weeks ago
@dserodio your command works fine if you use a full path for your directories
linuxrawkstar · 320 weeks ago
@linuxrawkstar No, in that case find will print the full path and diff will report every line as not matching. The point of using relative directories and the cd command is for diff to filter out the common (relative) paths.
mbirk · 320 weeks ago
The information you have posted is very useful. The sites you have referred was good. Thanks for sharing... go" rel="nofollow">http://personeriadebarranquilla.gov.co/?option=com_k2&view=itemlist&task=user&id=3107'>go to my blog
bojokey283 · 42 weeks and 2 days ago
This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it go to my blog http://personeriadebarranquilla.gov.co/?option=com_k2&view=itemlist&task=user&id=3107
bojokey283 · 42 weeks and 2 days ago
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. lamps
bojokey283 · 41 weeks ago
I love the way you write and share your niche! Very interesting and different! Keep it coming! coronavirus isla mujeres
bojokey283 · 40 weeks and 6 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. rug cleaning
bojokey283 · 40 weeks ago
This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article. cpanel license
bojokey283 · 37 weeks and 6 days ago
Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. isla mujeres tour
bojokey283 · 37 weeks and 2 days ago
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.. schlüsseldienste köln
bojokey283 · 37 weeks ago
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing tulum
bojokey283 · 35 weeks and 4 days ago
Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. cenote manati
xoheko1229 · 34 weeks and 2 days ago
I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. rumah pintar
bojokey283 · 33 weeks and 4 days ago
Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place.. what is the weather in cozumel mexico
xoheko1229 · 32 weeks and 4 days ago
Impressive web site, Distinguished feedback that I can tackle. I am moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards. cancun attractions
xoheko1229 · 32 weeks ago
I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point, You just got a new biggest fan!.. holbox ferry
xoheko1229 · 31 weeks and 4 days ago
I found your this post while searching for information about blog-related research ... It's a good post .. keep posting and updating information. best hotel in holbox
xoheko1229 · 31 weeks and 4 days ago
Thank you a bunch for sharing this with all of us you actually realize what you are talking about! Bookmarked. Please also seek advice from my site =). We could have a hyperlink change contract between us! treatnheal
xoheko1229 · 30 weeks and 1 day ago
Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting. treatnheal
xoheko1229 · 29 weeks and 5 days ago
Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck. http://www.bracescarolina.com">Braces Raleigh Orthodontics
xoheko1229 · 29 weeks and 4 days ago
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. Inteligentny dom
xoheko1229 · 29 weeks and 3 days ago
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. Automatyka hoteli
bojokey283 · 29 weeks and 1 day ago
I really enjoyed reading this post, big fan. Keep up the good work and please tell me when can you publish more articles or where can I read more on the subject? luxury bathroom vanity
bojokey283 · 28 weeks and 2 days ago
This is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great. best resorts in tulum for couples
xoheko1229 · 27 weeks and 3 days ago
Great article with excellent idea!Thank you for such a valuable article. I really appreciate for this great information.. covid playa del carmen
bojokey283 · 27 weeks and 1 day ago
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me. Hualien food guide
xoheko1229 · 27 weeks ago
This is actually the kind of information I have been trying to find. Thank you for writing this information. Hualien to Taipei
bojokey283 · 26 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: