0

Here is an example of an associative array:

declare -A contains=( 
['sass']=exist")

I wish to check if 'sass' is present in a variable. So my next line is:

if [[ '????' = 'sass' ]]
  etc
  etc

However, i not sure what to put in the if statement to check the first part of the associative array.

Any help is appreciated, Thanks!

Kingswoop
  • 148
  • 8
  • 1
    `if [[ ${contains[sass]} ]]`; there's no `=` involved anywhere. – Charles Duffy Feb 03 '20 at 23:08
  • 1
    ...keep in mind that an associative array can have any number of keys, so you can't just retrieve "the key part" and operate on it; the nearest you could do is to iterate over the list of *all* the keys, but that's very inefficient compared to just asking for a lookup of the specific one you're looking for. – Charles Duffy Feb 03 '20 at 23:09

0 Answers0