Our relationship with ideacode has proved to be a trusting and productive one. As our data needs have grown, ideacode has worked closely with us to provide a successful, powerful system.

919-341-5170

help@ideacode.com

 

Blazing a trail to better facilities management.

Linux

Finding files common amongst two (or more) directories

I've been preparing for a conference next week, so I haven't had much time to write.  This week, I'll leave you with a little useful command line fu.

The problem: you have two directories, called v1 and v2.  v2 is mostly like v1, except there are maybe some new files in v2 or v1 has files v2 doesn't.  The need: list the files that appear in both.

find v[12] -type f | cut -f 2- -d / | sort | uniq -c | grep '^      2'

Which finds all files in "v1" and "v2", removes the leading directory part, sorts them in order to count how many times each line appears, and limits to those that appear twice.

Syndicate content