bash command line arguments
I want to make a script that can take command line arguments and run like this:
./script --domain=domain.com --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
chmod +x XXX.sh
this is supposed to be funny?
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.
That's exactly what I was looking for
|All times are GMT -5. The time now is 04:52 PM.|