I have an if/else statement in a bash script that's asking if an EBS volume is going to be created from a snapshot id.
I'd like to create a line like: if [ "$from_snapshot" -eq "Y|y" ] but I don't think that will work.
Here's what I have:
if [ "$from_snapshot" -eq "Y" ]
then
echo "Enter Snapshot ID: "
read -r snapshot_id
elif "$from_snapshot" -eq "y"
echo "Enter Snapshot ID: "
read -r snapshot_id
else
echo "No Snapshot Required"
fi
If there any way I can state that more succinctly?
case $from_snapshot in [Yy]) echo "yes code goes here";; *) echo "other code goes here";; esacfor a baseline-POSIX approach.[[ ${from_snapshot^} = Y ]]or[[ ${from_snapshot,} = y ]]