Re: find -exec command
2006-11-02, 12:44(-06), Todd H.:
[...]
>> > find test -newer last_backup -exec tar rvf backup.tar '{}' \;
>> >
>> > Where test = folder containg files
>> > last_backup = specified file
>> > backup.tar = new file
>> >
>> > It will work in Solaris, unfortunately the system i need to back up is
>> > LINUX. I can get the 'find -newer last_backup' to work fine however the
>> > -exec bit doesnt work, every file is tar'd instead of just the newer
>> > ones.
>> [...]
>>
>> If using GNU tar, add the --no-recursion option to tar.
>>
>> Alternatively, you may want to add "! -type d" to find.
>
> I've never used single ticks around the {} with a find -exec. Try it
> without those and see if it becomes happy.
That would make no difference. The single ticks are for the
shell to tell it to take the {} characters litterally (which
most shells do anyway already even without the '...').
In both cases, find will be given an argument containing the two
characters "{}".
The problem the OP is having is that find will select the
*directories* that are newer than the "last_backup" file. And
GNU tar, when given a directory, will archive the directory plus
every file it contains by default. Hence the --no-recursion to
revert that default behavior.
--
Stéphane
|