CAREFUL HERE!

WATCH OUT FOR FILES WITH WHITE SPACES IN THEIR NAMES!

I'd do:

find /home -iname "*.bmp" -type f -print0 | xargs -0 /bin/rm -f

Or as someone suggested - move them somewere else or put them in
a tar file, something like:

find /home -iname "*.bmp" -type f -print0 | \
  tar --files-from - --null --create --append --bzip2 \
      --remove-files --file bmp-files.tar.bz2

The above will find all regular files with names ending with
"*.bmp" (case INsensitive) and move them to a bzip2'ed tar
file.

Consider use of "-xdev" for find to stay on local filesystem.

You might better go through "man find" and "man tar" to see if you
can make use of other tweaks (e.g. tar's --atime-preserve if you care).

The above command was NOT testted, so practice on private temporary
files (and double-check the command line) before unleashing it on
unsuspecting filesystems.

I personally hate using "grep" on output of "ls" (or "ps" for that
matter), many times it's not accurate enough and may catch "false
positives".

-exec for find(1) is quite passe(sp?) today with xargs(1) around, IMHO.

Cheers,

--Amos

Sebastian Welsh wrote:
On Wed, 2004-09-22 at 09:12 +1000, Simon Bryan wrote:

Hi all,
We have run out of space in our user directory file. All users have been
warned to delete or convert the thousands of bmp files to soemthing else
or they will be deleted. So now I want to carry out my threat. I can list
them all with

ls -alR |grep bmp

but how do I feed something like that to 'rm'


More fun with find

find . -name "*.bmp" -exec rm {} \;

Alternatively

ls -alR | grep bmp | xargs rm

would do the trick but I'd advocate using a stronger regular expression
as otherwise

buysimonnewibmpc.doc in the accounts directory goes, too.

Cheers, Seb.


-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to