I am new to Unix shell scripting and would like some help with writing small script.
I have defined a following synopsis for my script:
install.sh [-h|-a path|[-k path][-f path][-d path][-e path]]
ie user can request some help (-h), install all to a specified place (-a path), or install one or more of a components (-k, -f, -d -e) to a appropriate paths. If there is no arguments, the help should be shown.
Thanks in advance.
You can use
getoptsto parse a command line withbash. Here is an example taken from Bash/Parsing command line arguments using getopts (obviously you’d have to adjust the options to your needs).Related SO question How do I parse command line arguments in bash?
For more information search for
getoptson this man page for bash.