[plug] strncmp in shell
James Devenish
devenish at guild.uwa.edu.au
Mon Jan 19 14:21:20 WST 2004
In message <20040119055137.GE4110 at patrick.wattle.id.au>
on Mon, Jan 19, 2004 at 01:51:37PM +0800, Cameron Patrick wrote:
> What I want to do is say something like
> if [ "$FOO[0-6]" = "wurble" ]; then (do stuff) fi
I'm not sure about this one, since neither bash nor zsh include regex
matching nor linguistic string conversion. One option that springs to
mind is to change the ASCII case of one of the arguments to match that
of the other (might require changing both, though -- hmm). For example,
in zsh, you would use $NAME:l instead of $NAME. Perhaps a more general
solution is to use regex, such as 'if fgrep -i wurble <<< "$FOO[0-6]" &>
/dev/null; then...'
More information about the plug
mailing list