Shell script help
Björn König
bkoenig at cs.tu-berlin.de
Wed Jun 29 08:35:38 GMT 2005
Mike Jeays wrote:
> "man expr" to give the short answer to your first question:
>
> As an example, x=`expr $x + 1`
>
> 536 ~ $ x=4
> 537 ~ $ x=`expr $x + 1`
> 538 ~ $ echo $
>
> Note the back-quotes to execute a command and return the result, and the
> need for spaces between each token in the expr command.
sh(1) is able to evaluate arithmetic expressions too, e.g.
x=$(($x+1))
Björn
More information about the freebsd-questions
mailing list