find – two or more exec options – FIND MANY EXEC EXECS – to execute multiply commands with find

2 EXECS IN A FIND
#################
# find -iname “*ip*” -exec echo {} \; -exec cat {} \;
SAMPLE OUTPUT:
./if-post-down.d/my-iptables-save.sh      <—– echo {} \; running — for first match
iptables-save -c > /etc/iptables.rules       <—– cat {} \; running — for first match
./if-pre-up.d/my-iptables-restore.sh         <—– echo {} \; running — for second match
iptables-restore -c < /etc/iptables.rules       <—– cat {} \; running — for second match
SYNTAX:
find [options] -exec [command1 using {} as placeholder for filename] ;\ -exec [command2 using {} as placeholder for filename] ;\
THE BUILDING BLOCK IS:
-exec [command1 using {} as placeholder for filename] ;\
NOTE: Each exec runs in order as they appear per file. Not exec command1 on every file, and then command2 on every file. IN OTHER WORDS: Its more like file1 gets command1 and command2 ran on it, then file2 gets command1 and command2 ran on it, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *