I am writing a script which can choose a file and print specific content. For example,
san#./script.sh
Expected Usage : ./script.sh --file1 --dns
(Here it checks for file1, search for dns name and prints. Basically there are sub-parameters under a parameter)
I tried for single parameter/Option as below :
options=$@
arguments=($options)
index=0;
for argument in $options
do
index=`expr $index + 1`;
case $argument in
-a | --fun1 ) run_function1 ;;
-b | --fun2 ) run_function2 ;;
-c | --fun3 ) run_function3 ;;
esac
done
exit;
[ ${1} ] || helpinfo
Can any one suggest for double parameter(sub options) ?
Expected target options :
./script.sh
OPTIONS : ./script.sh -h
./script --fun1 stackoverflow
microsoft
Google
--fun2 Yahoo
Basically each function will look into one file. I have looked into getopt or getopts, But it doesn't have long option (--long
is not possible, instead we can use only -l
). But again not sure of sub parameters. Can any one help on this ?