Help with UNIX alias, need 2 word alias

gregulator

Senior member
Apr 23, 2000
631
4
81
Well I need to alias a phrase but dont know how to do it. Like:

alias powermt config='cfgmgr -vl powerpath0'

but I get errors on invalid name. I need to alias the phrase "powermt config" Thanks for the help.
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
That'll be seen as a command and an argument either way you do it.
Why do you need that whitespace?

Anyway, you could always make a bash script that doesn't take any arguments, called "powermt" that in turn executes "cfgmgr -vl powerpath0".
That way you could run "powermt config" and the config part would just be ignored while the cfgmgr command gets executed by the script.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Hm, escaping the spaces doesn't work. It registers the alias, but you can't use it.

Do this:

powermt() {
if [ "x$1" = "xconfig" ]
then
cfgmgr -vl powerpath0
else
echo "bad argument"
return 1
fi
}

I think that should work how you want.

(hit quote on this message to see the correct indentation (although indentation technically doesn't matter for shell :p))