Reputation: 12190
I have been trying to get my menu to work, however it seems that it only accepts one argument/option at a time, how can I get it to accept multiple options?
#!/bin/bash
##### Main
function usage
{
echo "
usage: infinidb [[-f file ] [-i] | [-h]] name ...
}
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
filename=$1
;;
-i | ) filename2=$2
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
echo $filename
echo $filename2
when running the script
the following output show show
./script.sh -f apple -i tree
apple tree
Upvotes: 0
Views: 224
Reputation: 3694
This works for me
#!/bin/bash
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
filename=$1
;;
-i ) filename2=$2
;;
esac
shift
done
echo $filename
echo $filename2
There was only a problem with -i | )
Upvotes: 1