Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to read input from a file named 'input.txt' using stdin redirection.
Linux CLI
cat [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' or '>>' which redirect output instead of input.
Just writing the filename without '<' does not redirect stdin.
✗ Incorrect
Using '< input.txt' redirects the content of 'input.txt' as standard input to the 'cat' command.
2fill in blank
mediumComplete the command to count the number of lines in 'data.txt' using stdin redirection.
Linux CLI
wc -l [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the filename without '<' which makes 'wc' treat it as an argument.
Using '>' or '>>' which redirect output, not input.
✗ Incorrect
Using '< data.txt' sends the file content as input to 'wc -l' which counts lines.
3fill in blank
hardFix the error in the command to sort the contents of 'list.txt' using stdin redirection.
Linux CLI
sort [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the filename without '<' which makes 'sort' treat it as an argument.
Using '>' or '>>' which redirect output and overwrite the file.
✗ Incorrect
To sort contents from a file using stdin redirection, use '< list.txt' so 'sort' reads from the file.
4fill in blank
hardFill both blanks to filter lines containing 'error' from 'log.txt' using stdin redirection and grep.
Linux CLI
grep [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the filename as an argument instead of redirecting input.
Forgetting to quote the search pattern.
✗ Incorrect
Use 'grep "error" < log.txt' to search for 'error' in the file by redirecting input.
5fill in blank
hardFill all three blanks to print words longer than 5 letters from 'words.txt' using stdin redirection and awk (assuming one word per line).
Linux CLI
awk '[1] [2]' [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' for input redirection.
Omitting the print action in awk.
Not quoting the awk script properly.
✗ Incorrect
Use 'awk 'length($0) > 5 {print $0}' < words.txt' to print words (lines) longer than 5 characters from the file.