Help for "if condition" - need your help

Hi Friends
Need you help on this.
i used below line in my script

#! /bin/bash
read var
if  [ "$var" != "0" ] || [ "$var" != "Q1000" ]
then
    echo "YES"
else
    echo "NO"
fi

i want conditoin not equal Q1000 - Q1999 in my script.
i try below.

#! /bin/bash
read var
if  [ "$var" != "0" ] || [ "$var" != "Q1???" ]
then
    echo "YES"
else
    echo "NO"
fi

and

#! /bin/bash
read var
if  [ "$var" != "0" ] || [ "$var" != "Q1[000-999]" ]
then
    echo "YES"
else
    echo "NO"
fi

but not work.

Please help.

Thank

 if [[ $var != "0" ]] && [[ ! $var =~ Q1[0-9][0-9][0-9] ]]

syntax error at source line 1
context is
{if( ! $var >>> =~ <<<

my os = sunos

The example you got from aia did not have a parenthesis in it

# yours
if( ! $var >>> =~ <<< 
# note spaces are needed  on BOTH sides of any of these: [ ] [[ ]]
# because they are keywords bash like if or read
# should be:
if [ ! $var

i try use awk + if

|awk -F"."  '{if( $2 != "Q1[0-9][0-9][0-9]" ) print $2}'  |sort |uniq -c |sort -k1nr |head -n6

can help me.

awk is definitely not needed. Depending on your bash version, Aia's proposal (type in as presented!) should work satisfyingly.
If it doesn't, pls. post your bash versions, the script you tried to run, error messages verbatim, and an execution log (set -x option).

Change to:

'{if( $2 ! ~  /Q1[0-9][0-9][0-9]/ )  print $2 }

the /pattern goes here/ thing delimits a regular expression pattern, which is what you are using. It works with the ~ character instead of the = character.

If you change anything else, please give more of your code to work with.

It'work.

Thank All.

read var
if [[ $var != Q1[0-9][0-9][0-9][0-9] ]]
then

Unlike [ ] the [[ ]] does not do expansion then word splitting.
The quotes are not needed - in fact they prevent the special meaning of [0-9]