bash - How to check if any array element is not holding a specific string -


is there way of checking elements in array, , if elements in array not holding string mystring return true? example, if element of array 2 elements holding mystring want make return false, else true:

[mystring][mystring] = false/don't [mystring][a] = false/don't [@#$2][mystring]=false/don't [asda][wrwe]=true 

q: how can check array n elements, if none of elements within array hold other value other mystring should return true?

my attempt was:

    element_number in `seq 0 $going_through_the_elements_of_the_array`;               my_var=${the_array[$element_number]}                   if ! [[ $my_var == "$my_string" ]]                                      echo " should printed"                      exit                 fi     done     

this should want:

case ${the_array[@]} in   *my string*) echo "true" ;;   *) echo "false" ;; esac 

it expands array single string uses re mechanism in case statement search target. case found prints true, other cases print false.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -