Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove all backup files in Linux using Shell script recursively [duplicate]

How can I remove all backup files, i.e files ending with ~, recursively in a particular folder in Ubuntu?

A script in any programming language would do.

like image 905
Janmejay Avatar asked Jan 06 '13 21:01

Janmejay


People also ask

How do I delete backup files in Linux?

Type the rm command, a space, and then the name of the file you want to delete. If the file is not in the current working directory, provide a path to the file's location. You can pass more than one filename to rm . Doing so deletes all of the specified files.

How remove all files in a directory Linux?

To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r . Directories that are removed with the rmdir command cannot be recovered, nor can directories and their contents removed with the rm -r command.


1 Answers

For one, you could use a simple find command:

find . -type f -name '*~' -delete
like image 68
knittl Avatar answered Oct 13 '22 20:10

knittl