Groups | Search | Server Info | Login | Register
Groups > alt.comp.lang.shell.unix.bourne-bash > #278
| From | Lewis <g.kreme@kreme.dont-email.me> |
|---|---|
| Newsgroups | alt.comp.lang.shell.unix.bourne-bash |
| Subject | Re: Comparing strings |
| Date | 2021-07-14 00:07 +0000 |
| Organization | Miskatonic U |
| Message-ID | <slrnsesalh.2gfo.g.kreme@m1mini.local> (permalink) |
| References | <cbd56071-17a6-4133-93df-496eef153e06n@googlegroups.com> <scl09g$23t$1@dont-email.me> |
In message <scl09g$23t$1@dont-email.me> Michael F. Stemper <michael.stemper@gmail.com> wrote: > 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" ]] There's a difference between [[ ]] and [ ] ([[ ]] is superior and you should probably just get used to using [[ ]] exclusively). But the syntax used in the sample above is incorrect, i believe, as single brackets require that you use -o for or. you really only need to deal with single [ ] if you want to be compatible with sh. -- "Are you pondering what I'm pondering?" "I think so, but where is a fish?"
Back to alt.comp.lang.shell.unix.bourne-bash | Previous | Next — Previous in thread | Find similar
Comparing strings ELCV <clsamcmaster@gmail.com> - 2021-07-13 10:46 -0700
Re: Comparing strings Grant Taylor <gtaylor@tnetconsulting.net> - 2021-07-13 14:29 -0600
Re: Comparing strings Lewis <g.kreme@kreme.dont-email.me> - 2021-07-13 21:00 +0000
Re: Comparing strings ELCV <clsamcmaster@gmail.com> - 2021-07-13 18:53 -0700
Re: Comparing strings ELCV <clsamcmaster@gmail.com> - 2021-07-14 08:42 -0700
Re: Comparing strings Grant Taylor <gtaylor@tnetconsulting.net> - 2021-07-14 09:58 -0600
Re: Comparing strings ELCV <clsamcmaster@gmail.com> - 2021-07-14 10:09 -0700
Re: Comparing strings Grant Taylor <gtaylor@tnetconsulting.net> - 2021-07-14 11:37 -0600
Re: Comparing strings Lewis <g.kreme@kreme.dont-email.me> - 2021-07-14 23:34 +0000
Re: Comparing strings "Michael F. Stemper" <michael.stemper@gmail.com> - 2021-07-13 16:23 -0500
Re: Comparing strings Lewis <g.kreme@kreme.dont-email.me> - 2021-07-14 00:07 +0000
csiph-web