Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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'm writing small programs that are allowing me to do common commands with just two or three words max like sudo apt-get update I made it upt something like that

Now I'm trying to write a script which will allow me to install programs from terminal the command is sudo apt-get install 'program'

I'm asking here how can I save the command 'program' in a variable to use it in my script so I can write in terminal inst 'program' ?

share|improve this question
up vote 3 down vote accepted

When you invoke a script like

myscript parameter1 parameter2

the parameter1, parameter2 etc. values from the command line are available inside the script as positional parameters $0, $1, ... etc

  • parameter $0 contains the name by which the script was invoked (myscript)
  • parameter $1 contains the value parameter1
  • parameter $1 contains the value parameter2
  • and so on

So in your case if you want to run your script like

inst program

to install program, then inside the script you can write

apt-get install "$1"

See for example Handling positional parameters at

share|improve this answer
thank you very much for the help :) – user123418 Jan 3 '14 at 21:19

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.