- 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:
- find . : where? - in this directory
- -type f : only normal files, no directories
- -exec : what to do with the ones found
- bash -c command invoke bash and read commands from string, where
- ( foo ; bar ) > list : () invokes a subshell so that all output from commands are redirected to the file list
- {} is subsituted by the filename found by find
- do not forget to enclose your command by ''
- the "" around the filename is for, your gess, spaces in the filename