Here's a simple example:
#!/bin/bash # http://www.tutorialspoint.com/unix_commands/getopt.htm usage() { echo usage: $0 -- --ge0IP 10.132.56.250 --ge1IP 192.168.99.1 exit 1 } # read the options TEMP=`getopt --long ge0IP:,ge1IP: -- "$@"` eval set -- "$TEMP" # extract options and their arguments into variables. while true ; do case "$1" in --ge0IP) ge0IP=$2 ; shift 2 ;; --ge1IP) ge1IP=$2; shift 2 ;; --) shift; break ;; *) usage ;; esac done set | grep ^ge
The output is:
$ getoptions -- --ge0IP 10.132.56.250 --ge1IP 192.168.99.1 ge0IP=10 ge1IP=11