Re: How to execute more than one command with find -exec?
From: Cheng Mo (mo.cheng_at_nospam.nospam)
Date: 11/19/04
- Next message: Bill Marcum: "Re: Question about group permission"
- Previous message: Ross: "Question about group permission"
- In reply to: noi: "Re: How to execute more than one command with find -exec?"
- Next in thread: noi: "Re: How to execute more than one command with find -exec?"
- Reply: noi: "Re: How to execute more than one command with find -exec?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 19 Nov 2004 09:30:51 +0800
noi wrote:
> On Thu, 18 Nov 2004 17:35:30 +0800, Cheng Mo thoughtfully wrote:
>
>
>>The scenario is:
>>In folder XXX there are lots of *.gif files. Those *.gif files whose
>>filename don't appear in file abc.txt should be deleted. I want to do this
>>job in one line command.
>>find XXX -name "*.gif" -exec ........... \; But I don't know how to write
>>the part of ..............
>>
>>I tried
>>find XXX -name "*.gif" -exec grep {} abc.txt || rm {} \; But it seems
>>-exec don't take behind as a combination of two commands. Anybody can tell
>>me how to execute more than one command with find -exec? Thanks
>
>
>
> Seems complicated with find. Alternative?
> tar -zcf gif.tgz -T abc.txt && find XXX -iname "*.gif" -exec rm {}\;
>
> In your example,
>
> find XXX -iname "*.gif" | grep -v -f abc.txt | xargs rm
find XXX -iname "*.gif" will output filename with XXX as prefix, but in
abx.txt only filename is written. How to cut those XXX?
- Next message: Bill Marcum: "Re: Question about group permission"
- Previous message: Ross: "Question about group permission"
- In reply to: noi: "Re: How to execute more than one command with find -exec?"
- Next in thread: noi: "Re: How to execute more than one command with find -exec?"
- Reply: noi: "Re: How to execute more than one command with find -exec?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]