Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Check if a Bash array contains a value

if [[ " ${array[*]} " =~ " ${value} " ]]; then
    # whatever you want to do when array contains value
fi

if [[ ! " ${array[*]} " =~ " ${value} " ]]; then
    # whatever you want to do when array doesn't contain value
fi
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Check #Bash #array
ADD COMMENT
Topic
Name
1+6 =