I edit text files on Linux and always end up with tons of backup files ending with ~ all over the place! How do you get rid of it?
If you edit files on linux, with emacs, vi, kate and others, chances are you'll end up with a lot of those backup files with names ending with ~, and removing them one by one is a pain.
Lucky enough, with a simple command you can get them all, and recursively. Simply go into the top of the directory tree you want to clean (be carefull, these commands are recursive, they will run through the subdirectories), and type
find ./ -name '*~' | xargs rm
Some explanations:
- the command
find ./ -name '*~'will look for all files ending with~in the local directory and its subdirectories, - the sign
|is a 'pipe' that makes the outout of the previous command becoming the input of the next one, xargsreads the arguments on the standard input and applies it to the following commandrmdeletes whatever file you want.
And if you need a little help for all those unix commands, I really recommend the book Unix in a Nutshell. It's really good, with a nice summary of the most important Unix commands, shell references, and all those things you keep forgetting about sed, regular expressions, or vi.
Edited and reformatted 10/2005
xcristi, 05 November 2005
If you have problem with the last variant (find: missing argument to `-exec'), write this way:
find ./ -name '*~' -exec rm '{}' ';' -print
Silvia, 24 June 2006
For find: missing argument to `-exec` error, I use:
find ./ -name '*~' -exec rm '{}' ; -print
Silvia, 24 June 2006
Sorry, it's: find ./ -name '*~' -exec rm '{}' \; -print (the slash disappears at submit)
Cezar, 23 November 2007
for correctly handling files with spaces in their names:
find . -name "*~" -type f -print0|xargs -0 rm
a, 06 December 2008
find ./ -name '*~' | xargs rm
does not work
bitebi, 07 July 2010
Cheap Chanel http://www.chanelbags1.com/
Your website came up in...[/link]
Chanel Bracelet http://www.chanelbags1.com/chanel-camellia-bracelet-p-25.htm...
Guess Men's Watches http://www.watches-user.com
Longines Watches
D&G ladies watches [link=http://www.my-own-watches.com/dgladies-watches0020-p-4420.html]http://www.my-own-watches.com/dgladies-watches0020-p-4420.ht...
Breitling http://www.watches-lover.com/
Cheap Chanel handbags...[/link]
Chanel handbags for cheap http://www.chanelbags1.com/chanel-cambon-bag-blackwhite-p-33...
MBT shoes http://www.mbtshoes-discountstore.com/
MBT Men'...[/link]
Five fingers http://www.vibram1-fivefingers.com/
poonam menon, 29 July 2010
clear my backup files
poonam menon, 29 July 2010
clear my backup files
ConcordWatches, 12 August 2010
Specializing in <a href="http://www.replicawatchesmart.com/"><stron...[/link]">Swiss Replica Watches</a>, <a href="http://www.replicawatchesmart.com/">Cheap Wat...[/link]">Wholesale Watches</a>, <a href="http://www.replicawatchesmart.com/rolex-watches-c-32.html[/l..."><strong>A.Dunhill Watches</strong></a>, <a href="http://www.replicawatchesmart.com/alangesohne-watches-c-180....">A.Lange&Sohne Watches</a>, <a href="http://www.replicawatchesmart.com/alain-silberstein-watches-...">Alain Silberstein Watches</a>, <a href="http://www.replicawatchesmart.com/audemars-piguet-watches-c-...">Audemars Piguet Watches</a>, <a href="http://www.replicawatchesmart.com/brm-watches-c-151.html[/li...">Baume & Mercier Watches</a>, <a href="http://www.replicawatchesmart.com/bellross-watches-c-36.html...">Bell&Ross Watches</a>, <a href="http://www.replicawatchesmart.com/blancpain-watches-c-183.ht...">Blancpain Watches</a>, <a href="http://www.replicawatchesmart.com/bmw-watches-c-31.html[/lin...">Breguet Watches</a>, <a href="http://www.replicawatchesmart.com/breitling-watches-c-28.htm...">Breitling Watches</a>, <a href="http://www.replicawatchesmart.com/index.php?main_page=news_a...">Replica Watches</a>, <a href="http://www.replicawatchesmart.com/burberry-watches-c-86.html...">Burberry Watches</a>, <a href="http://www.replicawatchesmart.com/bvlgari-watches-c-76.html[...">Calvin Klein Watches</a>, <a href="http://www.replicawatchesmart.com/carl-f-bucherer-watches-c-...">Carl F. Bucherer Watches</a>, <a href="http://www.replicawatchesmart.com/cartier-watches-c-90.html[...">Chanel Watches</a>, <a href="http://www.replicawatchesmart.com/chopard-watches-c-71.html[...">Christian Dior Watches</a>, <a href="http://www.replicawatchesmart.com/chronoswiss-watches-c-190....">Chronoswiss Watches</a>, <a href="http://www.replicawatchesmart.com/concord-watches-c-156.html...">Concord Watches</a>, <a href="http://www.replicawatchesmart.com/corum-watches-c-100.html[/...">D&G Watches</a>, <a href="http://www.replicawatchesmart.com/de-witt-watches-c-127.html...">De Witt Watches</a>, <a href="http://www.replicawatchesmart.com/esprit-watches-c-218.html[...">Ebel Watches</a>, <a href="http://www.replicawatchesmart.com/emporio-armani-watches-c-1...">Emporio Armani Watches</a>, <a href="http://www.replicawatchesmart.com/fendi-watches-c-157.html[/...">Ferrari Watches</a>, are given the correct care and treatment. <a href="http://www.replicawatchesmart.com/fossil-watches-c-225.html[...">Franck Muller Watches</a>, <a href="http://www.replicawatchesmart.com/girard-perregaux-watches-c...">Girard Perregaux Watches</a>, <a href="http://www.replicawatchesmart.com/glashutte-watches-c-158.ht...">Glashutte Watches</a>, <a href="http://www.replicawatchesmart.com/graham-watches-c-16.html[/...">Gucci Watches</a>, <a href="http://www.replicawatchesmart.com/guess-watches-c-17.html[/l...">Hamilton Watches</a>, <a href="http://www.replicawatchesmart.com/harry-winston-watches-c-16...">Harry Winston Watches</a>, <a href="http://www.replicawatchesmart.com/hermes-watches-c-18.html"><strong>Hermes Watches</strong></a>, For a long period of time she had been demanding one of those expensive watches that she had seen in an exclusive showroom.
ben, 17 August 2004
or you can use :
find ./ -name '*~' -exec rm {} ; -print
This will execute the command rm for any files found. -print is optional, but it is nice to see what you are deleting!