summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLumenTeun <anton@lutic.org>2014-08-08 18:24:43 +0100
committerLumenTeun <anton@lutic.org>2014-08-08 18:24:43 +0100
commite1365274f7f9217a035b3e078fd7586eeef5f886 (patch)
tree57c4334915ad8cf254f0ef00dd1ccabed6d43bac
parent43209662626cdb4ed4b9e656a72c092512c4e9cc (diff)
Added two new ways to use for loops.
-rw-r--r--bash.html.markdown14
1 files changed, 14 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 2056a9ea..061d35b0 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -140,6 +140,20 @@ do
echo "$VARIABLE"
done
+# They can also be used to act on files..
+# This will run the command 'cat' on file1 and file2
+for VARIABLE in file1 file2
+do
+ cat "$VARIABLE"
+done
+
+# ..or the output from a command
+# This will cat the output from ls.
+for OUTPUT in $(ls)
+do
+ cat "$OUTPUT"
+done
+
# while loop:
while [ true ]
do