Home

Wiki (private)

 Kornel 

 Blog Kornela 

Linux

Drugs

Berlin

Outside

Free Time

Contact

Impressum


Fun with find
What you may forget using -exec : always end your exec-statement with
<space>\; - it does not work if you forget the leading space!
In need of multiple statements to exec? Invoke a shell:
find . -type f -exec bash -c '(echo "{}" ; diff "localfiles/{}" "/opt/installation/files/{}") > list' \;
If the later needs some explanation:
  1. find . : where? - in this directory
  2. -type f : only normal files, no directories
  3. -exec : what to do with the ones found
  4. bash -c command invoke bash and read commands from string, where
  5. ( foo ; bar ) > list : () invokes a subshell so that all output from commands are redirected to the file list
  6. {} is subsituted by the filename found by find
  7. do not forget to enclose your command by ''
  8. the "" around the filename is for, your gess, spaces in the filename