find and non-recursion

finally i learned some real unix basics again –
I needed to created a script, which – after the 3rd change in input format and requirements – was supposed to delete data off a netapp filer nfs share used by many SAP systems.
like, in the following list of directories, delete every file not changed since 20071231.

cd /dir
find .! -name . -prune -type -f -mtime +870 -exec rm {} +

the most charming bit is the “+” at the lines end: it will use a mechanism like xargs, but one builtin to find, saving the 100000s process forcs coming with xargs.

see the following site, especially looking for platforms supporting “+”:

“some notes about find”


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s