
05-27-2009
|
|
Shell programmer, author
|
|
|
Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
|
|
Quote:
Originally Posted by glamo_2312
Hi,
I have created a script which will move the file passed as $1 to a particular folder.
In the .profile of my unix user i have created an alias as
alias rm="$HOME/script"
Now i want that to do
alias rm="$HOME/script"
alias \rm="$HOME/script"
alias \rm -rf ="$HOME/script"
alias rm -rf ="$HOME/script"
It does not take rm -rf as ab alias.
How to do this.
|
Use functions, not aliases.
Code:
unalias rm
rm()
{
if [ "$1" = "-rf" ]
then
shift
$HOME/script "$@"
else
command rm "$@"
fi
}
|