diff --git a/episodes/04-loops.md b/episodes/04-loops.md index fef6c29e..05a0fb38 100644 --- a/episodes/04-loops.md +++ b/episodes/04-loops.md @@ -138,12 +138,13 @@ Alternatively, rather than running the loop above on the command line, you can s ``` #!/bin/bash -# This script loops through .txt files, returns the file name, first line, and last line of the file +# This script loops through .txt files, returns the file name, +# first line, and last line of the file for file in *.txt do - echo $file - head -n 1 $file - tail -n 1 $file + echo "$file" + head -n 1 "$file" + tail -n 1 "$file" done ``` diff --git a/episodes/files/my_first_bash_script.sh b/episodes/files/my_first_bash_script.sh index 4cd0315f..be0891d7 100644 --- a/episodes/files/my_first_bash_script.sh +++ b/episodes/files/my_first_bash_script.sh @@ -1,8 +1,10 @@ #!/bin/bash +# This script loops through .txt files, returns the +# file name, first line, and last line of the file -for filename in *.txt +for file in *.txt do - echo $filename - head -n 5 $filename - tail -n 5 $filename -done \ No newline at end of file + echo "$file" + head -n 1 "$file" + tail -n 1 "$file" +done