programming languages - Bash: check if element is in an array -


im trying make work next bash code, seems im doing things wrong:

hostname=`hostname -s` qaiservers={'v-qai01' 'v-qai02'}   in ${qaiservers[@]}         if [[ $i = ${hostname} ]];                 echo 1         else                 echo 0         fi done 

the current hostname v-qai01 supposed match verification, doesnt:

./run.sh: line 14: v-qai02}: command not found ./run.sh: line 15: }: command not found 

thank you

fixed:

made work with:

hostname=`hostname -s`  qaiservers=("v-qai01" "v-qai02") #portales={'t1wsyellar01' }  in "${qaiservers[@]}"     if [ "$i" == "${hostname}" ] ;         echo "found"     fi done 

made work link

qaiservers=('v-qai01' 'v-qai02') 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -