0
0
Linux CLIscripting~10 mins

Why text processing is Linux's superpower in Linux CLI - Test Your Understanding

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

Complete the code to display the first 5 lines of a file named 'data.txt'.

Linux CLI
head -[1] data.txt
Drag options to blanks, or click blank then click option'
A5
B10
C15
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number larger than 5 will show more lines than needed.
Forgetting the dash before the number causes an error.
2fill in blank
medium

Complete the command to find lines containing the word 'error' in 'log.txt'.

Linux CLI
grep [1] log.txt
Drag options to blanks, or click blank then click option'
A'error'
B'debug'
C'info'
D'warning'
Attempts:
3 left
💡 Hint
Common Mistakes
Searching for the wrong word will not find the needed lines.
Omitting quotes can cause errors if the word has special characters.
3fill in blank
hard

Fix the error in the command to count lines in 'file.txt'.

Linux CLI
wc -l [1]
Drag options to blanks, or click blank then click option'
A-file.txt
Bfile.txt
Cfiletxt
D--file file.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Adding dashes before the filename causes errors.
Misspelling the filename leads to 'file not found' errors.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 letters in a list.

Linux CLI
{word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using the wrong comparison operator in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than 0.

Linux CLI
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase keys instead of uppercase.
Including items with zero or negative values.