Hello, On Tue, 28 Jul 2009, David C. Rankin wrote:
What is a shorter way to do multiple case insensitive tests on a string or variable that would accomplish this:
[[ $line == QUIT ]] || [[ $line == Quit ]] || [[ $line == quit ]] && break
Basically what I am looking for is some case insensitive way to test for quit or exit without having to define a test for each possible permutation without bringing in a big hammer like sed or the like. I am a bit confused on the test expansion but know things like $line == [Qq]uit won't work.
I can do it in case:
case $line in [Qq][Uu][Ii][Tt] ) break;; esac
But that seems like a clunky use of case. Is there a better way?
Using case is the canonical way. But you could also use: test -z "${line#[Qq][Uu][Ii][Tt]}" && break HTH, -dnh -- Every feature is a bug, unless it can be turned off. -- Karl Heuer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org