1832255 Members
2492 Online
110041 Solutions
New Discussion

ksh alias with argument

 
Stefan Schulz
Honored Contributor

ksh alias with argument

Hello,

i try to reduce typing by setting up an alias. The problem is that i don't know how to use an argument in an alias.

E.g. i try to replace the command:

mv filename /daten/bx/ABC.drw/ABC1001.drw

with an alias like

bxABC1001 filename

the alias would look something like:

alias bxABC1001='mv xxx /daten/bx/ABC.drw/ABC1001.drw'

Where xxx should be substituted with the argument.

Any hints? Any documents who describe alias better than the man pages?

Thanks in advance

Stefan
No Mouse found. System halted. Press Mousebutton to continue.
3 REPLIES 3
Tom Geudens
Honored Contributor

Re: ksh alias with argument

Hi,
In my opinion that is not possible (at least not in the way you want it). The following thread covers this issue :
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x996e7e990647d4118fee0090279cd0f9,00.html

Hope this helps,
Tom Geudens
A life ? Cool ! Where can I download one of those from ?
federico_3
Honored Contributor

Re: ksh alias with argument

alias test='set +u;mv $1 /daten/bx/ABC.drw/ABC1001.drw ; set -u'

After this use the following to move filename


test filename

Ciao
Federico
Peter Kloetgen
Esteemed Contributor

Re: ksh alias with argument

Hi,

Frederico:

don't use "test" as name for an alias for the move- command, test is also a command!!

Stefan:

hi Stefan,

i would prefer to make a function for this, you can put this function into a file with the same name as the function and use it as often as you want:

function mover
{
mv $* /your/desired/target/directory
}

This function can be used the following way:

mover file1 file2 file3 file4 .....

Remember, how to create the function:

vi mover (*must* be the same name than function)
put the line : mover $* under the function. As root, make sure, that the directory of the function is part of your PATH!
PATH=$PATH:/path_to_your_function

This will do it for you!!

Allways stay on the bright side of life!

Peter
I'm learning here as well as helping