From 8be20de321b2331ab717319ca3c57c460a85de7f Mon Sep 17 00:00:00 2001 From: LumenTeun Date: Fri, 8 Aug 2014 18:11:17 +0100 Subject: Fixed while loop. --- bash.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index 845ebead..96f2414d 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -141,7 +141,7 @@ do done # while loop: -while [true] +while [ true ] do echo "loop body here..." break -- cgit v1.2.3 From 43209662626cdb4ed4b9e656a72c092512c4e9cc Mon Sep 17 00:00:00 2001 From: LumenTeun Date: Fri, 8 Aug 2014 18:24:29 +0100 Subject: Fixed typo. --- bash.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bash.html.markdown') diff --git a/bash.html.markdown b/bash.html.markdown index 96f2414d..2056a9ea 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -134,7 +134,7 @@ case "$VARIABLE" in esac # for loops iterate for as many arguments given: -# The contents of var $VARIABLE is printed three times. +# The contents of $VARIABLE is printed three times. for VARIABLE in {1..3} do echo "$VARIABLE" -- cgit v1.2.3 From e1365274f7f9217a035b3e078fd7586eeef5f886 Mon Sep 17 00:00:00 2001 From: LumenTeun Date: Fri, 8 Aug 2014 18:24:43 +0100 Subject: Added two new ways to use for loops. --- bash.html.markdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'bash.html.markdown') 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 -- cgit v1.2.3