Skip to content

Commit 01cf055

Browse files
author
Scott Peterson
authored
?.txt instead of *.txt for loop example
The lesson was changed from using the touch command to create .doc files to .txt files, but since there are also a number of other .txt files in this directory, when you run the loop it changes all the .txt files, not just the newly created ones: a.txt b.txt c.txt d.txt. To make is so the loop only changes the newly created .txt files, you need to write the code in the loop as ?.txt and not *.txt. This will give you the correct output. This example could be created outside the shell-lesson directory, but learners could also have .txt files there too. If we don't want to use the ?.txt, then we could go back to creating .doc files for this example.
1 parent 85f4be2 commit 01cf055

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

_episodes/04-loops.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ We can apply this to our example like this:
4545

4646

4747
~~~
48-
$ for filename in *.txt
48+
$ for filename in ?.txt
4949
> do
5050
> echo "$filename"
5151
> cp "$filename" backup_"$filename"

0 commit comments

Comments
 (0)