tags:

views:

64

answers:

1

The question emerged my original question here.

I try to find the common elements between the outputs of the two find-commands with a find-command. How can I get the command working?

find `find ~/bin/FilesDvorak/.* -maxdepth 0` -and `find ~/.PAST_RC_files/.*`
+2  A: 

Would something like this work instead, rather than reinvent the wheel?

diff -qrs ~/bin/FilesDvorak/ ~/.PAST_RC_files/ | grep -P "are identical|differ"

You can play around with the grep to get the files present only in one of the dirs, etc.

diff

  • -q --brief Output only whether files differ.
  • -r --recursive Recursively compare any subdirectories found.
  • -s --report-identical-files Report when two files are the same.

grep

  • -P: Perl style regex. You can probably do away just fine without it though, I usually add it automatically.
Artem Russakovskii
The option -P for grep seems to be only for Ubuntu. What is its purpose? I want to find a similar command for Mac too.
Masi
The options -q, -r and -s seem to be too Ubuntu-only. Could you explain their purpose? I want to convert the command for Mac too.
Masi
There's nothing that's Ubuntu only - diff is FSF and grep is GNU - they're available on all flavors of Linux and I don't see why they shouldn't be available on Macs.
Artem Russakovskii
Updated the solution with options explanation. In general, you can 'man CMD' to get its manual and explanation of all options or just look it up online.
Artem Russakovskii