Re: Scripting Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Steven W. Orr" wrote:

> On Wednesday, Oct 15th 2003 at 15:20 +1000, quoth John Colville:
>
> =>Jake McHenry wrote:
> =>
> =>> > -----Original Message-----
> =>> > From: shrike-list-admin@xxxxxxxxxx
> =>> > [mailto:shrike-list-admin@xxxxxxxxxx] On Behalf Of Stephen Mah
> =>> > Sent: Tuesday, October 14, 2003 7:49 PM
> =>> > To: shrike-list@xxxxxxxxxx
> =>> > Subject: Re: Scripting Question
> =>> >
> =>> >
> =>> > you can probably use the find command, to find files that are
> =>> > older than
> =>> > 4 days. Use the -exec option to remove the file.
> =>> >
> =>> Something like this?
> =>>
> =>> find /archive/backup/sql* -mtime 4 -exec rm -f -r
> =>>
> =>> That gives me an error: find: missing argument to `-exec'
> =>>
> =>> The man page isn't very good on find. It helped a lot, but some of the
> =>> stuff is kinda fuzzy.
> =>>
> =>> Jake
> =>>
> =>
> =>You need to add '{} \;' to the above to make it work I think.
> =>i.e.
> =>
> =>find /archive/backup/sql* -mtime 4 -exec rm -f -r {} \;
>
> Everyone should learn the xargs command.
>
> find /archive/backup/sql* -mtime 4 -print | xargs rm -f
>
> Note that the rm command is not getting the -r option because we are not
> deleting directories, only files.  If you use -exec you will be starting
> one seperate chile process for every file to be deleted. This is not a big
> deal for small problems, but it is a huge deal for huge trees. By using
> xargs, you are reducing the number of child processes to a *very* small
> number.
>

Thanks Steven. I'm happy to use xargs - I've always found the braces solution
far too cryptic anyway !
Cheers, John

>
> --
> -Time flies like the wind. Fruit flies like a banana. Stranger things have -
> -happened but none stranger than this. Does your driver's license say Organ
> -Donor?Black holes are where God divided by zero. Listen to me! We are all-
> -individuals! What if this weren't a hypothetical question?
> steveo at syslang.net
>
> --
> Shrike-list mailing list
> Shrike-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/shrike-list


-- 
Shrike-list mailing list
Shrike-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/shrike-list

[Index of Archives]     [Fedora Users]     [Centos Users]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat Phoebe Beta]     [Yosemite Forum]     [Fedora Discussion]     [Gimp]     [Stuff]     [Yosemite News]

  Powered by Linux