![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I want to know how we can give alias entry in cron | naree | SUN Solaris | 1 | 03-12-2008 05:46 AM |
| Please give your inputs !!!! | kpatel786 | Shell Programming and Scripting | 9 | 04-27-2007 07:59 AM |
| if i give this command what would be the value... | suri | Shell Programming and Scripting | 1 | 03-05-2007 11:06 PM |
| Give us a hand | RichardB | UNIX for Dummies Questions & Answers | 3 | 05-06-2002 08:37 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
i want to give alias
Hi all,
I m giving an alias to a command in bash shell under solaris o.s. As following. alias "rm -r"="sh /dir1/move.sh" It is throwing an error: -bash: alias: `rm -r': invalid alias name Please can anyone help me out for this. Thank U Naree |
| Forum Sponsor | ||
|
|
|
|||
|
This is tricky because you have to pass through to the "real" rm if it's not the -r option. Do you want to catch rm -r -i or -ri too, or just rm -r?
Code:
rm () { # use a function instead of an alias
case $1 in -r) shift; # get rid of the -r
dir1/move.sh "$@";;
*) /usr/bin/rm "$@" ;;
esac
}
|
|
|||
|
I want to do for all
Dear all,
I want to do for all -i -r -f etc. according i have done like this MOVE.sh --------- case $1 in *) sh /dir1/move.sh ;; esac And i have created alias as following alias rm="sh /dir1/MOVE.sh" Even though it is not working. Please help me out for this issue. Thank U Naree |
|
|||
|
The whole case statement is redundant if you don't want any cases. You are not passing on the arguments to the function, that's the "$@" up there. But unless your move.sh already knows how to deal with -r, -i, -f, and other rm options, this is not the way to do it. If it does, good for you. But then you could simply have used alias rm=/dir1/MOVE.sh in the first place.
|
|||
| Google UNIX.COM |