mardi 24 mars 2020

Bash string comparision

Please help.

I'm trying to compare string1 against string2 in a Bash script.

I can do the easy bit of:-

if [[ $string1 == $string2 ]]
then    
    yippee    
fi

What I'm having trouble with is the syntax for when

"the$string1" == $string2  or "a$string1" == $string2

or

 $string1 == the$string2 or $string1 == a$string2

I assume it's something like:-

if [[ $string1 == $string2 || "(a|the)$string1" == $string2 || $string1 == "(a|the)$string2" ]]

But it's not and I cannot seem to find the answer. (I'm obviously asking the wrong question!)

Thanks for any help.

PS I'd rather not use any external progs such as awk etc.

Aucun commentaire:

Enregistrer un commentaire