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
Post a Comment