[X-Unix] bash problem: `expr index $somestring somepattern` fails
Steffen Lund Hokland
hokland at mr.au.dk
Sat Oct 30 00:48:28 PDT 2004
Hi,
I'm writing a bash script and needed something along the lines of:
`expr index $somestring somepattern`
for parsing a text string. This is described in:
'Advanced Bash-Scripting Guide: An in-depth exploration of the art of
shell scripting' version 2.7.7. However when running the command above
i get an error:
expr: syntax error
Apparently this happens whenever using 'expr' with 'index', 'length',
'match' and 'substring' this occurs. I've tried running the example
script 12.9 (the file is called ex45.sh in my download), and get this
error message whenever `expr index/length/match/substring ......`
occurs.
Does anybody know what's wrong. I know that there are far better ways
of parsing a text string (awk, perl...), but it just bugs me....
Thanks in advance,
Steffen
More information about the X-Unix
mailing list