Skip to content

Commit e2e1cf8

Browse files
committed
grep review command
1 parent 2ce0147 commit e2e1cf8

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

individual-shell-tools/grep/script-03.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ set -euo pipefail
55
# TODO: Write a command to output the number of lines in dialogue.txt that contain the word Doctor (regardless of case).
66
# The output should be exactly the number 9.
77

8-
grep -n "Doctor" dialogue.txt -i | wc -l
8+
grep -i -c "Doctor" dialogue.txt
9+
910

individual-shell-tools/grep/script-07.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ set -euo pipefail
55
# TODO: Write a command to output, for each `.txt` file in this directory, how many lines of dialogue the Doctor has.
66
# The output should show that dialogue.txt contains 6 lines, dialogue-2.txt contains 2, and dialogue-3.txt contains 0.
77

8-
for f in *.txt; do
9-
echo "$f: $(grep -i "^Doctor:" "$f" | wc -l)"
10-
done
8+
grep -i -c "^Doctor:" *.txt

0 commit comments

Comments
 (0)