From: Lynne Williams Date: Sun, 17 Feb 2013 16:54:03 +0000 (-0500) Subject: Update shell_cheatsheet.md X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7a4f2fd6e56f8b8ca45bae85c02c809dacd433fe;p=swc-boot-camp.git Update shell_cheatsheet.md --- diff --git a/shell_cheatsheet.md b/shell_cheatsheet.md index d3671a4..36fcc16 100644 --- a/shell_cheatsheet.md +++ b/shell_cheatsheet.md @@ -116,17 +116,42 @@ where, . list[n]=Mark +which is referenced in the loop by: + + for varname in ${list[@]} + do + command 1 + command 2 + done + + _Note:_ Bash is zero indexed, so counting always starts at `0`, not `1`. ### b) While Loop -* **`while`** --> - `count=0 - while ${count} -lte 6 - do - COMMAND HERE - done` + COUNTER=0 + while [ ${COUNTER} -lt 10 ]; do + command 1 + command 2 + COUNTER=`expr ${COUNTER} + 1` + done + +where + + + +#### b.1) Conditional operators + +| Operator | Definition | +|----------|--------------------------| +| `-eq` | is equal to | +| `-ne` | is not equal to | +| `-gt` | greater than | +| `-ge` | greater than or equal to | +| `-lt` | less than | +| `-le` | less than or equal to | + ### b) That the loop variable takes on a different value each time through the loop... ### c) The difference between a variable's name and its value...