Afficher un message
Vieux 03/11/2006, 12h04   #7
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: find -exec command

2006-11-03, 11:55(+01), Michal Nazarewicz:
> mark.pollard@cwfi.co.fk writes:
>
>> I am currently struggling with a command that will look for files newer
>> than a specified file and tar them to a new file in a bash shell. The
>> command I am trying to use is
>>
>> find test -newer last_backup -exec tar rvf backup.tar '{}' \;

>
> You're taring directories as well, try:
>
> find test -type f -newer last_backup -exec tar rvf backup.tar {} \;
>
> BTW. If you don't care much about portability and have GNU tools, you
> may try faster method:
>
> find test -type f -newer last_backup -print0 | \
> xargs -0 --no-run-if-empty tar rvf backup.tar


Why use non-standard features when the standard find has a
better equivalent:

find test ! -type d -newer last_backup -exec \
tar rvf backup.tar {} +

(note that -type f is not the same as ! type d).

--
Stéphane
  Réponse avec citation
 
Page generated in 0,05586 seconds with 9 queries