Linux Command to Delete Backup Files Created by Bluefish
Whenever I am in Linux, I use the Bluefish editor for all my sites. Sometimes, I have to be in Windows for a few programs. When that happens, I use Pspad.
The problem is that Bluefish creates backup files which is the filename plus a ~. Bluefish hides those backup files, but Pspad shows them. This makes the file list look very cluttered. I want Bluefish to create the backup files, so I don't want to disable it, but I want to delete them when I am in Windows. I was thinking that this command would take care of it:
rm -r *~
...but it doesn't. Could somebody help me with the correct syntax to delete all backup files in my home directory using a shell session? Thanks.
02bunced posted this at 18:45 — 2nd January 2007.
He has: 412 posts
Joined: May 2005
Does rm -rf *~ work any better
pr0gr4mm3r posted this at 18:55 — 2nd January 2007.
He has: 1,502 posts
Joined: Sep 2006
That actually works, but only in the current directory. Doesn't the -r switch mean recursive (delete in all subdirectories)?
02bunced posted this at 21:09 — 2nd January 2007.
He has: 412 posts
Joined: May 2005
Yes, but it won't search through the subdirectories, it just works on the sub-directory names. This boils down to the Linux theory that everything is a file, therefore, it sees the subdirectories as a file only. So, if you had a subdirectory with the name "Project1~", the directory would be deleted, but it wouldn't search through it.
To do that, you'd need to set up a bash script to get the number of subdirectories in the folder, to 'cd' into each one, remove all the folders, cd back to the root again and repeat for each directory.
pr0gr4mm3r posted this at 21:52 — 2nd January 2007.
He has: 1,502 posts
Joined: Sep 2006
Ok, I see now. Thanks for the clarification.
I've never written any bash scripts to do something complex like that. If anybody would be able to come up with something that would work, I would appreciate it. Otherwise, I can do it in PHP.
JeevesBond posted this at 06:18 — 3rd January 2007.
He has: 3,956 posts
Joined: Jun 2002
The easiest way to solve this is to get Bluefish to delete all it's backup files when it closes.
This definitely doesn't require a bash script: just use the pipe! This should work:
find . -type f -name '*~' | xargs rm -f
'So [incode]find . -type f -name '*~'[/incode] finds (the [incode]-type f[/incode] bit) any files in the current directory (the dot after the find), which have a name ending with '*~'. The pipe symbol [incode]|[/incode] then sends the results of the find to [incode]xargs rm -f[/incode], xargs gets the results and calls [incode]rm -f[/incode] for each file, which deletes them.
The find command is recursive.
A while ago I always used to login to my Linux box as root, that was until I typed: [incode]rm -rf /[/incode] by accident. Big mistake.
a Padded Cell our articles site!
JeevesBond posted this at 06:22 — 3rd January 2007.
He has: 3,956 posts
Joined: Jun 2002
Just had a look at Bluefish, to make it delete the backups on exit, go to Edit -> Preferences -> Files -> Backup -> Remove backup file on close (it's a checkbox).
Otherwise you can just use the commands above, changing the preferences does seem easier though.
a Padded Cell our articles site!
02bunced posted this at 08:08 — 3rd January 2007.
He has: 412 posts
Joined: May 2005
Thanks JeevesBond - long time since I've used Linux so my command line knowledge is failing . . .
pr0gr4mm3r posted this at 14:31 — 3rd January 2007.
He has: 1,502 posts
Joined: Sep 2006
My Bluefish program is configured to delete backup files upon closing. It doesn't like to listen.
That command works! Thanks so much.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.