0
0
Linux CLIscripting~10 mins

wc (word, line, character count) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to count the number of lines in a file named 'file.txt'.

Linux CLI
wc [1] file.txt
Drag options to blanks, or click blank then click option'
A-w
B-l
C-c
D-m
Attempts:
3 left
💡 Hint
Common Mistakes
Using -w or -c instead of -l will count words or bytes, not lines.
2fill in blank
medium

Complete the code to count the number of words in 'document.txt'.

Linux CLI
wc [1] document.txt
Drag options to blanks, or click blank then click option'
A-w
B-l
C-m
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -l counts lines, not words.
Using -c or -m counts bytes or characters.
3fill in blank
hard

Fix the error in the command to count characters in 'notes.txt'.

Linux CLI
wc [1] notes.txt
Drag options to blanks, or click blank then click option'
A-w
B-l
C-m
D-c
Attempts:
3 left
💡 Hint
Common Mistakes
Using -c counts bytes, which can be different from characters.
4fill in blank
hard

Fill both blanks to count lines and words in 'story.txt'.

Linux CLI
wc [1] [2] story.txt
Drag options to blanks, or click blank then click option'
A-l
B-w
C-c
D-m
Attempts:
3 left
💡 Hint
Common Mistakes
Using -c or -m instead of -w for word count.
Mixing up line and character options.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each filename to its word count, only if the word count is greater than 100.

Linux CLI
result = [1]: [2] for [3] in files if [2] > 100}}
Drag options to blanks, or click blank then click option'
Afile
Bwc -w file
Dfilename
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable names.
Not filtering word counts correctly.