Expr command
From DD-WRT Wiki
(Difference between revisions)
Revision as of 18:43, 12 April 2007 (edit) Mj6Qgv (Talk | contribs) m ← Previous diff |
Revision as of 19:00, 9 January 2009 (edit) (undo) Alvin (Talk | contribs) m Next diff → |
||
Line 1: | Line 1: | ||
+ | You are here: '''[[Main_Page|DD-WRT wiki mainpage]] / [[Telnet/SSH_and_the_Command_Line|SSH/Telnet & The CLI]] / expr ''' | ||
+ | |||
'''expr''' is the expression command in bourne type shells. On the WRT, expr is handled by busybox. | '''expr''' is the expression command in bourne type shells. On the WRT, expr is handled by busybox. | ||
Line 4: | Line 6: | ||
- | ~ # '''expr 5 6''' | + | ~ # '''expr 5 6''' |
- | + | 11 | |
- | 11 | + | |
- | + | ||
- | + | ||
- | 9 | + | ~ # '''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. | Try '''expr --help''' for more details. |
Revision as of 19:00, 9 January 2009
You are here: DD-WRT wiki mainpage / 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.