using asteriks in if statement in bash scripting

Hi Experts,

if [[ "$DBS" -eq 1 && "$DBS" -ne VFEEDBACK* ]]
 then
        DS=`echo "$i"`

How do I write the if statement in the correct way
DevSupportAsked:
Who is Participating?
 
DevSupportConnect With a Mentor Author Commented:
@pawan kumar:

I couldnt get that to work so I rewrote the script like this:

if [[ "$DBS" -eq 1 && "$DBS" != VFEEDBACK* ]]

this works.

Thanks for your help anyways!
0
 
Pawan KumarDatabase ExpertCommented:
Pls try-

if [[ "$DBS" -eq '1' && "$DBS" -ne 'VFEEDBACK*' ]]
0
 
DevSupportAuthor Commented:
@Pawan Kumar: Thank You, but I tried it and got an error, line 51: [[: VFEEDBACK*: syntax error: operand expected (error token is "*")
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Pawan KumarConnect With a Mentor Database ExpertCommented:
dont have system with me to check .. try this

if [[ "$DBS" -eq '1' && "$DBS" -ne VFEEDBACK'*' ]]
0
 
tel2Commented:
Nice work, DevSupport.

Do you understand the reason your answer works?  If not, read on...
If you run the command:
    man test
you'll see that operators like "==" and "!=" are for comparing strings, and "-eq", "-ne", etc, are for comparing integers.

Also note that if, for example, "VFEEDBACK*" had a space (or various other characters) in it, like "VFEED BACK*" or "VFEEDBACK *", you'd need to surround it with quotes.
0
 
DevSupportAuthor Commented:
because my response works
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.