PDA

View Full Version : How to run multiple commands in linux Find -exec



Fli
11-03-2014, 08:24 PM
How to execute more commands in Linux Find command?

"-exec" is used to execute commands on the found folders/files

Here is example of multi commands Find:


find . -type f -iname "*.png" -exec optipng -o2 {} \; -exec chown myusername:myusername {} \; -exec chmod 544 {} \;


we have 3 execs, 3 commands executed on (in this case) .png files found in current directory/subdirectories
-exec COMMAND HERE {} \;

{} is used as an replacement of a found file or folder (file in this case)