shell programming question: help with expr command

Dino Vliet dino_vliet at
Sat Apr 9 13:43:49 UTC 2011

Hi folks,
I'm having trouble with a little shell script. Can somebody explain me why I get 3 times "expr: syntax  error" in my console after I run this little script?

#! /usr/local/bin/bash
# testscript 

var1="trees.J48" #other value will be rules.Jrip, rules.DecisionTable
ind=`expr index $var1 s`
pos=`expr $len - $ind`
out=`expr substr $var1 $ind $pos` 

I would expect (and want the following to happen):

$ind should contain 6
$pos should contain 3
$out should contain J48 (other values will have to be Jrip,DecisionTable)

Can anyone help me with this?


More information about the freebsd-questions mailing list