Linux/Unix - Search and remove files with one find command on fly

Some time it is necessary to find out files and remove them as we need to do today. However, rm command does not support search criteria.

However, with find command you can search for files in a directory and remove them on fly.

You need to combine find and rm command together.

Fortunately find command makes this operation quite easy.

You can use find command as follows:

find . -type d -print | grep <file_name/dir_name> | xargs -n1 rm -rf

Get free daily email updates!

Follow us!

No comments:

Post a Comment

Please provide valuable comments and suggestions for our motivation...

Popular Posts