Re: seeking thru a string in a shell script



On 2007-01-17, Chris the Hunter wrote:
expr length $str

Didn't work at my box, but thanks all the same

Probably because the variable should be quoted:

expr length "$str"

It's unlikely that a Linux distro would have an old version of expr
without the length operator.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.



Relevant Pages

  • Re: seeking thru a string in a shell script
    ... Chris F.A. Johnson wrote: ... It's unlikely that a Linux distro would have an old version of expr ...
    (alt.os.linux)
  • Re: command line calculator
    ... expr 1004 * 30 does not do it. ... echo "print eval).qq{ ... You didn't escape the asterisk. ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: command line calculator
    ... expr 1004 * 30 does not do it. ... echo "print eval).qq{ ... You didn't escape the asterisk. ... Shell Scripting Recipes: ...
    (comp.unix.shell)
  • Re: Why it does not work?
    ... And why are you using expr? ... Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ...
    (comp.unix.shell)