Restore

Nils Kassube kassube at gmx.net
Thu Apr 19 19:23:28 UTC 2007


On Thursday 19 April 2007 18:33, adams wrote:
> The rm command does not save anything anywhere.  That is why it is
> called "remove".  :-)
>
> But there is a way to get around it, but it requires some effort on
> the users part.
>
> In in the home directory add   alias rm="" to .bashrc and type that
> in for the current shell on a command line with the prompt

May I suggest you use this alias:

alias rm='echo "Do not use the rm command, use mv instead.";rm'

Please note: The rm command is still there. If you replace the rm command 
with a mv command, you get a feeling of safety because you think your 
alias will prevent desasters. Then on another machine the alias doesn't 
exist and you do remove the files (been there, done that).

> and this does away with user typing rm on a command line to remove
> a file.  It becomes a null command.
>
> Do a mkdir ~/trash  on the command line to create a "trash bin".
>
> Now the user must "mv file_name ~/trash"  to get rid of it, but
> it still exists.  To really really delete a file you/they have
> to type /bin/rm file_name  and because it requires thinking
> the user remembers that what they do will destroy the file.
>
> I was thinking that maybe in .bashrc one could do something
> like
>
> alias rm="mv $1 ~/trash"
>
> where $1 refers to the argument, but $1 is used in C-shell
> scripting,

No, that doesn't work. An alias accepts no arguments. You would need a 
function instead. It looks like this:

movetotrash () { mv -i $1 $HOME/trash; }


Nils




More information about the kubuntu-users mailing list