Operating System - HP-UX
1752839 Members
3870 Online
108789 Solutions
New Discussion юеВ

Re: '-exec cmd' in find command

 
SOLVED
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 ??? {} \;
3 REPLIES 3
Jan Sladky
Trusted Contributor
Solution

Re: '-exec cmd' in find command

Hi,

try

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

br Jan
GSM, Intelligent Networks, UNIX
Muthukumar_5
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!