Jump to content

Tired of taking forever to delete a directory?


static
 Share

Recommended Posts

Have you been at the command line and decided "OK directory fun/ - it's time to go" so you issue a "rm -R fun/" then had to hit 'y' for every single file in there?!?!?! That is such a long, tedious job. This doesn't happen because linux is configured that way, it happens because mandrake is configured that way. Here's how to fix it.

 

$ su

(Enter root password)

# vi /etc/profile.d/alias.sh

 

Scroll down to the aliases for cp, mv, and rm. You'll see they have aliased rm='rm -i' so that every time you type rm it asks if you're sure... OF COURSE YOU'RE SURE!! THAT'S WHY YOU TYPED IT!! Remove the -i or the whole alias and save by hitting ESC :wq

 

Now "rm -R fun/" = No more fun for you! Sweet!

 

Next time you enter a terminal it should take effect. Note I also get rid of all the ls aliases and cd aliases so that I don't get lazy and forget the real commands for when I'm on a solaris or other *nix box...

 

Disclaimer: static takes no responibility for people losing important configuration files or other data due to delete-crazy rampages. Use this tip wisely. Please rm responsibly.

Link to comment
Share on other sites

or you could just do:

rm -Rf fun/

or press one less key and do:

rm -rf fun/

 

dont forget, fun with *!

 

rm -rf fun*

I like using this when, say, i have a zip file called fun that i unzipped and then decided I didn't want it anymore. it will get rid of the directory AND the zip file!

 

same disclaimer as static...

Link to comment
Share on other sites

But be careful with

$ rm -rf fun*

 

It will delete both the directory and the zip file for fun, but it will also delete the folder named functions, an ebook named fundamentals_of_linux.pdf, etc.

Link to comment
Share on other sites

Correction:

explanation: * is a wildcard.  with the command i gave, any directory OR FILE that starts with fun will be deleted.

 

OK so considering you could just use the "f" switch to "force" the deletion, we'll say I posted this tip to advise you to not get lazy with your *nix commands. Edit your /etc/profile.d/alias.sh so that your linux box is like any other solaris, BSD or other unix flavour to make you a more valuable employee. Yeah, that's it! Yeah! Also, now you can add your own aliases, like

alias tr="tar -czf"

to create a tar.gz file, or anything you'd like to shorten the command of. Note this is the opposite of "not getting lazy with your *nix commands" but HEY! it's your box and you can do whatcha like to!

 

Note disclaimer above...

Link to comment
Share on other sites

Correction:
explanation: * is a wildcard.  with the command i gave, any directory OR FILE that starts with fun will be deleted.
[/i]
:oops: i'm just missing things left and right, aren't i?
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...