Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Ubuntu 9.04 and I use Quanta Plus for programming, but when I try to upload all folders to a server, all of the back up files (which have a tilde as the last character) are also uploaded.

I want to know is there any command by which I can recursively delete all of the backup files from a folder. Please provide a command for me, because it is not possible to delete each and every file manually.

share|improve this question
I have a script which does just this, I am trying to find it but I believe its on my work desktop. You call it with a path and a constraint to look for. In your case you could do "./ /path/to/folder/ *~ and it will remove all of your backup files containing the ~ on the end. Would you be interested in me posting it? – Chris Sep 10 '10 at 11:25
find /path/to/dir -name "*~" -delete


find /path/to/dir -name "*~" -ok rm {} \;

to prompt before removal

share|improve this answer
How would you exclude a directory with this method? The man page for find says: "Because -delete implies -depth, you cannot usefully use -prune and -delete together." – Shawn Apr 14 '14 at 15:44
@Shawn: Something like this (untested): find /path/to/dir -wholename './subdir/to/skip' -prune -o -name '*~' -ok rm {} \; You could use -exec instead of -ok if you don't need to confirm deletions (or you could use -i with rm as a different way of confirming). – Dennis Williamson Apr 14 '14 at 17:05
Thanks Dennis. If others are having problems, note that removing the leading period or adding a trailing slash to './subdir/to/skip' will break the script – Shawn Apr 14 '14 at 23:05

For a more graphical solution (and for backing up all those *~ files before you delete them), you could use gnome-search-tool

Leave "Name contains:" empty, select your folder, check the 'more' options: "Show hidden and backup files" + "Exclude other filesystems" (to prevent it from searching SSH servers, mounted Ftp folders and connected drives), and then for the magic bit, choose the 'more' option "Name matches regular expression:" and type in


Then after it's done searching you simply select which ones to remove, right-click and select "Move to Trash". I do it this way so I can backup all those files before permanently deleting them. I uploaded a screenshot here: "dl . elundmark . se / e / Selection-20120114-01 . jpg"

share|improve this answer


$ cd the_folder
$ rm -i `find -name '*~'`

The -i option prompts before every removal, you can remove it if you're sure.

share|improve this answer
thank you Cyrus – JustLearn Sep 10 '10 at 6:12
That will fail for filenames that contain spaces. – Dennis Williamson Sep 10 '10 at 6:15
@Dennis: You've right! – cYrus Sep 10 '10 at 6:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.