Skip to content

Tech Tip of the Day: Quick file deletion

Here’s another quick tip.  If you have a large directory tree (hundreds or thousands of nested levels), and you need to find and delete a set of files from the tree, consider this one-line approach:

cd [target-dir-top-level];for i in `find . -name \*tar.gz`; do rm -f $i; done

Replace my pattern ‘tar.gz’ with one that matches the files you wish to delete.

Tags: , ,

One Comment

  1. And here’s another one-liner:

    #find . -name *.tar.gz -exec rm {} \;

    Posted on 27-Aug-08 at 10:31 am | Permalink

Post a Comment

Your email is never published nor shared.