Showing results for 
Search instead for 
Did you mean: 

'-exec cmd' in find command

Go to solution
Gary Yu
Super Advisor

'-exec cmd' in find command

Dear all,

Does anyone know how to specify 2 parameters with the '-exec cmd' in find. e.g, I need to copy all files for the last week to another directoy, but it looks to me the cmd with -exec only takes one parameters(like rm), so how can I do that with one line, instead of a script:
find . -type f -mtime -7 -exec ??? {} \;
Jan Sladky
Trusted Contributor

Re: '-exec cmd' in find command



find . -type f -mtime -7 -exec cp {} /dir \;

br Jan
GSM, Intelligent Networks, UNIX
Honored Contributor

Re: '-exec cmd' in find command

Collected files on using find commands are given as {} to -exec option.

find . -type f -mtine -7 -exec cp {} /destination-dir/ \;

You can use multiple -exec there as,

find . -type f -mtine -7 -exec ll {} \; -exec cp {} /destination-dir/ \;
Easy to suggest when don't know about the problem!
Gary Yu
Super Advisor

Re: '-exec cmd' in find command

thank you guys, it works fine!