can't you just do:

alias rm='mv "$1" $HOME/trashdir'

that's how I'd do it (at first)... but then I'd realise that I'd lose use
of rm.. so I'd have to change it around a lil.. I'd have to give my
altered deletion command a slightly different name:

alias del='mv "$1" $HOME/trashdir'
alias rm='rm -i'

the second line would make sure that if you accidentally use rm instead of
del, that you'd be prompted. Remember that the 'f' option overrides the
'i' option. So doing 'rm -f' with the alias above, would actually be 'rm
-if'. The options cancel out.



On Wed, 14 Mar 2001, Vineeta wrote:

> Hi,
>    I want to copy any file prior to deletion to a dir. called trashdir
> in my home dir.
> I want to achieve this thru' a script.
> In fact i just tried a small script like this:
>
> cat testrmscript --contents of testrmscript file
> #!/bin/bash
> echo 'Rm script follows..'
> rm -i $1
> #res=$?
> if [ "$?" = "0" ]
> then
> cp $HOME/$1 ./trashdir
> else
> exit 1
> fi
>
> Where the arguement passed to the testrmscript is the file to be
> deleted.For eg. testrm2 is the file to be deleted.
> Now,i run the above script as follows:
> ./testrmscript testrm2
>
> It prompts me for deletion of the file.If i say "n" which means a value
> more than 0, it exits as expected.
> But,if i say "y" i.e. value of 0,it removes the file before copying it.
>
> Here,what i see the reason ,is that rm deletes the file before copy
> takes place.
> Can i interfere with rm prior to it performing the action?
>
> If this works,i can put this script in my .bash_profile and it'll be
> great.
>
> Any comments/suggestions would be great!
>
> Cheerio,
> Vineeta
>
>
>
> _______________________________________________
> Redhat-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-list
>

-- 
-Statux



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to