[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: testing, counting, & arithmetic in general
> Is this how I'm expected to do this type of operation in es?
> i=1
> while {test $i -le 10} {
> echo $i
> i=`{expr $i + 1}
> }
> I.e. use "/bin/test" for conditionals (where ~ and ~~ aren't
> appropriate) and "/bin/expr" for arithmetic operations?
Since there's no builtin shell arithmetic, the usual answer is yes.
I usually do the operations you're doing there with lists, but I'm the
first to admit that's a hack. For example,
x = 1
while {~ $x(10) ()} {
echo $#x
x = 1 $x
}
Subtraction is done with things like ``x = $x(2 ...)''.
It's awkward, but it works well for small integers.
Another approach, which is used for creating a sequence of numbers
that might be large is using awk or (if you have it, seq)
for (i = `{seq 212 451}) {
echo $i
}
Paul