Blog of Leonid Mamchenkov

You just stepped in a pile of posts.

This blog is discontinued. No more comments or pingbacks will be accepted. All new posts will appear in the new blog. Important posts from this blog will be edited and migrated to the new blog. Apologies for any inconvenience caused.

rm on steroids (a safer way)

Posted in All on June 28th, 2006 · 1 Comment

I came across an excellent tip about mixing rm and find commands in Linux shell.

The only thing I’d add to it is a bit of safety. Before executing the mix of find and rm, run the find command with the same options, but without rm. It will print out the files that match your search. These files are about to be deleted, so it’s a good thing to review them first.

By the way, I do exactly the same thing when working with SQL. If I need to delete something, I first create a SELECT statement that matches everything I need gone. And only when I am sure about the results, I change the SELECT to DELETE.

It’s been ages since I deleted something that I didn’t intend…

Update: Obviously, I haven’t read the comments before posting. My suggestions has already been suggested.

Tags:

1 response so far ↓