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.
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.
For one, you could use a simple find
command:
find . -type f -name '*~' -delete
One way:
find folder -name '*~' -print0 | xargs -0 rm -f
Basically, look at "man find"
First off, what do you mean by recursively? Recursion is a convenient way to implement dome algorithms, but tends to be over-used - but some people also apply the term to searching a directory tree (which can be implemented by other means that recursion). If you simply want to delete all files matching a specific glob in a directory tree then....
find /base/directory/ -type f -iname '*~' -exec rm -f {}\;
(but you might want to experiment with find /base/directory/ -type f -iname '*~' -exec ls -l {}\;
first).