Using case and arrays together in bash
5
votes
4
answers
15923
views
Is it possible to check if a variable is contained inside an array using
case
? I would like to do something like
ARR=( opt1 opt2 opt3 );
case $1 in
$ARR)
echo "Option is contained in the array";
*)
echo "Option is not contained in the array";
esac
Asked by red_trumpet
(345 rep)
Dec 15, 2017, 08:46 AM
Last activity: Dec 8, 2022, 03:41 PM
Last activity: Dec 8, 2022, 03:41 PM