Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to wrap 3 lines of execution into an alias, but I also need to pass a parameter when I call it in terminal.

Do I need to create a function for this?

I'm new to this, but I know there are functions in bash also.

alias blah=some_call_here; some_other_call $1; some_thing_here

The $1 in the above is the value I want to pass in when I call the alias. So to call it I want it to look like:

blah "some text"

Not that it has to be text that I pass in.

share|improve this question
up vote 3 down vote accepted

Aliases don't do parameters, so yes.

blah() { some_call_here ; some_other_call "$1" ; some_thing_here ; }
share|improve this answer
how could I set a default value if $1 wasn't passed in? – user27449 May 26 '11 at 20:48
With one of the other forms of parameter expansion.… – Ignacio Vazquez-Abrams May 26 '11 at 20:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.