Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quotes to variables in script #259

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions episodes/04-loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
12 changes: 7 additions & 5 deletions episodes/files/my_first_bash_script.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash
# This script loops through .txt files, returns the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small issue with formatting of this comment - doesn't match what is in the lesson

# 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
echo "$file"
head -n 1 "$file"
tail -n 1 "$file"
done
Loading