[Liverpool] shell script (sh) : variable contains string?
Dave Love
d.love at liverpool.ac.uk
Fri Sep 4 15:54:58 UTC 2009
Ben Arnold <iamseawolf at gmail.com> writes:
> I set the variable as a list of resolutions fine, I just can't find a clean way
> of seeing if (1024x768x[8|16|24]) exists in the pre-defined variable.
[...]
> NB -- It's an sh script, not bash. If it were bash, I could do
> [variable =~ text]
If the question is how to do pattern matching in portable sh, the
traditional way is like:
case ... in
*1024x768x24*) ... ;;
...
esac
and POSIX expr(1) has regexp matching. However, if you're using awk
anyway, why not just match with that?
More information about the Liverpool
mailing list