Linux Delete Directories or Files By Name

The Code

 find . -name "2013-*" -type d | xargs rm -rf

Explanation

We use the find command in the current directory(.) to search forĀ a name starting with 2013- followed by anything, which is of type d for directory.

We then pipe (|) the found directories over to the xargs command which runs the remove command (rm) with the options of recursive (r) and forced (f) for no confirmation prompts.

References

Previous Step

This entry was posted in Interesting Finds and tagged , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Trackback

Leave your thoughts...

Your email is never published nor shared. Required fields are marked *

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*
*