If I have a script called program and I want to set an option so that if -p is entered as an option then the program echoes "polly want a cracker", how should I go use getopt for this?
Asked
Active
Viewed 1,473 times
1 Answers
1
I give you a little example which you can develop for your own needs :
#!/bin/bash
while getopts "bp" OPTION
do
case $OPTION in
b)
echo "polly want a banana"
;;
p)
echo "polly want a cracker"
;;
esac
done
alifirat
- 2,789
- 1
- 15
- 33