Bash: check if hostname is v-q* how to use wildcards?

I have the next code and I need it to echo 1 if the hostname matches with v-qai01 or any other v-q* servers:

if [ `hostname -s` -eq `v-q*` ]; then
        echo "1"
fi

Im having several errors:

./run.sh: line 3: v-q*: command not found
./run.sh: line 3: [: v-qai01: unary operator expected

Any suggestions please?

What if I have the next case?

hostname=`hostname -s`

portalesWildcard=v-*ws*
qaiservers={'v-qai01' 'v-qai02'}
portales={'t1wsyellar01' }


if [[ ${hostname} = ${qaiservers} ]]; then
    echo "yes"
fi

Thanks

18
задан BoDiE2003 10 May 2011 в 20:00
поделиться