On Sunday 19 May 2002 18:46, Damian G wrote: > On Sun, 19 May 2002 17:36:28 -0400 > > Kirtis B <[EMAIL PROTECTED]> wrote: > > I was hoping that it'd be something simpler than that. For example > > could i use ls grep and rm together to search for all the files that > > end in .mp3 and are less than 500k and then delete them? I'm certain > > there is a way to do this, i just don't really know how to string the > > commands together properly and i don't want to accidently delete my > > entire mp3 collection. =) > > > > KIRT > You want to find the all the mp3 files that satisfy a criteria and delete them, right? Well, "find" is your friend:
find . -name "*.mp3" will list all files named *.mp3 that exist in . (i.e. the current directory) or any subdirectory of . Now what about the size requirement? I had a quick look at the man-page and became wiser: find . -name "*.mp3" -a -size -512k The -a stands for "and", the "-512k" stands for "less than 512k". Now all we need is to delete these files: You can do that with find, but I find it much simpler to pipe the search results from find into xargs: find . -name "*.mp3" -a -size -512k | xargs /bin/rm and this will run the /bin/rm command on the output from find, i.e. delete all the files that find returned from the search. Of course you have to be darn careful about this -- make sure you don't accidentally delete all your mp3 files! Check the output from find first, then append the "| xargs /bin/rm" part. Narfi.
Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com