Vijay
Vijay

Reputation: 67291

Creating an alias in solaris unix

I can create an alias in solaris as below:

alias x86 "some_command"

I need something that i can pass an argument to an alias and that argument will be used to frame the complete alias. for example:

there is a command like :

ct setview 1.0_myname

and for the above i write the alias as

alias sv "ct setview 1.0_myname"

in the above command 1.0 is the version and it can keep changing.

so what i want is to create an alias like :

alias sv "ct steview $1_myname"#well i donno whether this is correct

and i want to use this alias as sv 1.0 or sv 2.0

Upvotes: 1

Views: 5598

Answers (2)

alanc
alanc

Reputation: 4180

For csh & tcsh shells, there's limited argument substitution in aliases, using ! syntax, such as:

 alias sv 'ct steview \!:1_myname'

More details and examples at:

Upvotes: 0

pistache
pistache

Reputation: 6233

If you are using bash (or equivalent shell), the alias function cannot transmit arguments. Instead, you can create a function :

sv() { ct "setview $@_myname" ;}

And use it like an alias (sv 1.0)

Depending on your config you may need to provide full path of the ct binary

Upvotes: 1

Related Questions