Skip to content

Commit a36b9a4

Browse files
authored
Use clearer variable name
1 parent d1bdcbc commit a36b9a4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

episodes/04-loops.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ We have called the variable in this loop `filename` in order to make its purpose
101101
Complete the blanks in the for loop below to print the name, first line, and last line of each text file in the current directory.
102102

103103
```bash
104-
___ file in *.txt
104+
___ filename in *.txt
105105
__
106-
echo "_file"
106+
echo "_filename"
107107
head -n 1 _______
108108
____ __ _ _______
109109
____
@@ -114,11 +114,11 @@ ____
114114
## Solution
115115

116116
```bash
117-
for file in *.txt
117+
for filename in *.txt
118118
do
119-
echo "$file"
120-
head -n 1 "$file"
121-
tail -n 1 "$file"
119+
echo "$filename"
120+
head -n 1 "$filename"
121+
tail -n 1 "$filename"
122122
done
123123
```
124124

@@ -140,11 +140,11 @@ Alternatively, rather than running the loop above on the command line, you can s
140140
#!/bin/bash
141141
# This script loops through .txt files, returns the file name,
142142
# first line, and last line of the file
143-
for file in *.txt
143+
for filename in *.txt
144144
do
145-
echo "$file"
146-
head -n 1 "$file"
147-
tail -n 1 "$file"
145+
echo "$filename"
146+
head -n 1 "$filename"
147+
tail -n 1 "$filename"
148148
done
149149
```
150150

0 commit comments

Comments
 (0)