Terry Collins wrote:
> Damm, just tested above as
>
> find smtpd* -atime +7 -exec rm -f {} \;
>
> and found no quotes needed.
> head scratch.
But of course quotes are not required. The * is uninterpreted by the
shell not by find. Assuming smtpd1, smtpd2, smtpd.log are files in the
current directory, the above would be expanded to,
find smtpd1 smtpd2 smtpd.log -atime +7 -exec rm -f {} \;
by the shell *before* being executed. If however you want to do
find . -name 'smtpd*' -print
(I.E only files in all subdirs that start with smtpd) then you need the
quotes to stop the shell from converting that into
find -name smtpd1 smtpd2 smtpd.log -print
BTW given that your find statement will return directory names as well
as file names (and assuming you don't want to delete the directories)
then rm -f will try to do so and return an un-trapped error. So you
should probably add a -type f to find.
But congrats on resisting the politically correct push to use xargs, go
-exec I reckon. I've yet to see any real advantage in using xargs when
combined with find just the fact that you have to remember to add -0
because file names can have space in them these days, what a mess,
whereas exec rm -f {} works everytime, no dramas.
P.
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html