Re: Comparing strings

From: Michael F. Stemper (michae...)

On 13/07/2021 12.46, ELCV wrote:

> If I do this:
>
> if [ "$1" != "FOO" ];
> then
> echo "I can backup the 2nd volume";
> else
> exit;
> fi
>
> It works. But if I add an "or" condition as follows:
>
> if [ "$1" != "FOO" ] || [ "$1" != "BAR" ] ;

I've never seen this syntax. I always thought that the "or"
needed to be within the test, as in:

if [[ "$1" != "FOO" ||$1 != "BAR" ]]


--
Michael F. Stemper
Psalm 94:3-6

Share |
Comparing strings... by ELCV on Jul 13th 2021, 17:46