[Liverpool] shell script (sh) : variable contains string?
Ben Arnold
iamseawolf at gmail.com
Fri Sep 4 16:49:40 UTC 2009
On Friday 04 September 2009 16:54:47 Dave Love wrote:
> If the question is how to do pattern matching in portable sh, the
> traditional way is like:
>
> case ... in
> *1024x768x24*) ... ;;
> ...
> esac
On Thursday 03 September 2009 23:16:13 Jakub Ambrożewicz wrote:
> echo ${SCREEN_MODES} | grep '1024x768x' > /dev/null
> avail=$?
>
> if [ ${avail} -eq 0 ]; then
> echo "Found a 1024x768 resolution, setting as default."
Thanks to both of you for your responses. I prefer the more traditional &
perhaps readable methods so I'll use Dave's but Jakub's was interesting and on
my train of thought in terms of output. Think I was starting at it for too
long a time! Still, I've learned what $? etc. is :)
> However, if you're using awk anyway, why not just match with that?
Because I'm a pain! I think it's just how I use both utilities; awk does the
tidying and grep the finding. By breaking them up I've got both a full and tidy
list of modes, as well as the best 1024 to do things with.
Thanks to both of you for the help :)
Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://mailman.lug.org.uk/pipermail/liverpool/attachments/20090904/4496517d/attachment.pgp
More information about the Liverpool
mailing list