-   Linux - Software (
-   -   bash command line arguments (

izghitu 07-01-2010 07:16 AM

bash command line arguments

I want to make a script that can take command line arguments and run like this:
./script --path=/path --alias=alias1 --alias=alias2 --alias=aliasN

Is there any howto on how to do this or are there any docs? I am not sure what to google for and when I search for bash command line arguments I get docs about other style command line arguments that are of no use for me

Please help


subho.d 07-01-2010 07:35 AM

chmod +x

izghitu 07-01-2010 07:38 AM

this is supposed to be funny?

colucix 07-01-2010 08:02 AM

Since this thread has been forced out of the zero reply list... I'll start to tell something (hopefully) useful.

@izghitu: if you need to improve or refresh your general knowledge about bash scripting, better to start from the official documentation, for example:

Bash Reference Manual
Bash Guide for Beginners
Advanced Bash Scripting Guide

just to mention some of them. Command lines arguments are often referred as positional parameters. Inside a bash script you can retrieve their value using $1, $2, $3 and so on. Or you can parse them one at a time using the shift built-in in a loop. However, what you really need is a way to manage command line's options. In this case the getopts built-in or the getopt external command are your friends. You might start to look for all these terms in the cited documentation. Hope this helps.

izghitu 07-01-2010 10:23 AM

That's exactly what I was looking for


All times are GMT -5. The time now is 06:35 AM.