Check array for content
<p>I have an array like this:</p>

<pre><code>declare -A ignoreList='(
        [21]="1" 
        [22]="1"
        [25]="1" 
        [53]="1" 
        [80]="1" 
        [143]="1" 
        [587]="1" 
        [990]="1" 
        [993]="1" 
        [443]="1" 
        [2008]="1" 
        [10011]="1" 
        [30033]="1" 
        [41144]="1")'
</code></pre>

<p>Now i want to check if var $SSH_PORT in array ignoreList.</p>

<p>The var $SSH_PORT is this:
SSH_PORT="443"</p>

<p>if i try this:</p>

<pre><code>if [[ -v ignoreList[$SSH_PORT] ]]; then
                    echo "$SSH_PORT is known"
                    exit 1
                else
                    echo "$SSH_PORT is not known"
                    exit 1
                fi
</code></pre>

<p>i get this in terminal:</p>

<pre><code>443 is not known
</code></pre>

<p>but Port 443 is known. </p>

<p>so i try 
SSH_PORT="500" (not known)</p>

<p>and run the script:</p>

<pre><code>500 is not known
</code></pre>

<p>he dit not compare</p>

<p>if i try this:</p>

<pre><code>if [[ ${ignoreList[$SSH_PORT]} == 1 ]] ; then
echo In the list.
</code></pre>

<p>fi</p>

<p>it also did not work</p>

<p>my Bash version is 4.3</p>

<p>~# bash --version
GNU bash, version 4.3.42(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <a href="http://gnu.org/licenses/gpl.html" rel="nofollow">http://gnu.org/licenses/gpl.html</a></p>

<p>This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.</p>