-   Linux - Newbie (
-   -   prompting before removing (rm) folders (

charged 11-11-2008 09:49 PM

prompting before removing (rm) folders
Hello People,

My 1st post and I joined the forum to ask this question. I am using Red Hat Linux.
When I use the command
rm foo.whatever

It does not ask for confirmation that
" are you sure you want to delete file foo.whatever?" and just deletes. So if I use it by mistake it just deletes.

How can I configure rm to do that. Is there any way?

Thanks for any help regarding this :)

billymayday 11-11-2008 10:01 PM

Assuming you have .bashrc in your home directory, add

alias rm='rm -i'

to it and your bash shell will use rm -i instead of rm.

AuroraCA 11-11-2008 10:12 PM

One of the flag options that can be used with rm is -i which means "interactive". If you use the command:

rm -i filename
you will be asked for a confirmation before the file is removed.

You should know that the -i flag overrides previous -f flags (and vice versa) so if you use the alias suggested above the -f used after the alias rm command will override the -i flag.

charged 11-12-2008 05:36 AM

Thank you so much.

Another quick question though.

I do have ~/.bashrc but I am adding the line

alias rm='mv --target-directory ~/.Trash'

to it to redirect all removals to Trash instead of deleting them. So can I add both this line and the above suggested line in bashrc. Will both work?

Thank u again. And any help is gladly appreciated.

(yeah I had some bad experience with rm :) )

All times are GMT -5. The time now is 10:57 AM.