Expr command

From DD-WRT Wiki

Jump to: navigation, search

You are here: DD-WRT wiki mainpage / Scripting / SSH/Telnet & The CLI / expr

expr is the expression command in bourne type shells. On the WRT, expr is handled by busybox.

expr takes expressions. The most common expressions deal with simple arithmetic operations:


~ # expr 5 + 6
11
~ # expr 39 / 4
9

Loop counter example:

#!/bin/sh

# while lc < 10 do

lc=1
while [ $lc -lt 10 ] ;  do 
   lc=`expr $lc + 1`
   echo LoopCount: $lc
done

Try expr --help for more details.