Ubuntu: Recursively delete multiple files with specific format

Ubuntu: Recursively delete multiple files with specific format

Sometimes we have to delete files of specific format (common extensions, ends with ~, etc) which were spanned over a group of directories. To do so, we follow certain methods.

Lets do it by an example.
In my case, I've o create the temporary files, i.e., the ones ending with ~.

Method 1: Delete them manually
Method 2: Goto each such directory and run the following command
rm *~

Method 3:
rm *~
rm */*~
rm */*/*~
rm */*/*/*~

First two methods need more time and to use third method, we must know the depth of recursion.

Following method will solve our problem.

Method Friendly: Run the following command from the parent directory from which you are deleting the files.
find . -name '*~' -type f -delete
This will delete all files ending with ~, from the current directory and also all its sub-directories.

0 comments:

Post a Comment

Popular Labels

Featured Post (TOP)

Flickr Images

Follow Me on Facebook.com

Follow on Google+

Recent Posts

AD (728x60)

Pages

Powered by Blogger.

Labels

Followers

Popular Posts

Popular Posts

Subscribe Via Email

Sign up for our newsletter, and well send you news and tutorials on web design, coding, business, and more! You'll also receive these great gifts: