Reputation: 79
I have a trouble in a case-sensitive argument (bash), so basically when I type
./testfile -play
or
./testfile -p
or
./testfile -palalalal
the script has to run a "play" (name of function) that echo "test test 123" inside the testfile.sh
At the same time, it will also show error message like "invalid!" if I type
./testfile -PLAYYY
I really appreciate anyone that can help me. Thank you.
Upvotes: 0
Views: 267
Reputation: 939
Use case
operator:
case "$1" in
-p*) play ;;
-P*) echo "Invalid" ;;
*) echo "Still invalid" ;;
esac
Upvotes: 2