Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to save the output of ls command to a file files.txt while still showing it on the screen.
Linux CLI
ls | [1] files.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cat which only reads files.Using
grep or awk which filter or process text but don't split output.✗ Incorrect
The
tee command splits the output so it goes both to the file and the screen.2fill in blank
mediumComplete the code to append the output of date command to log.txt while still showing it on the screen.
Linux CLI
date | [1] -a log.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cat which does not write output to files.Using
head or tail which only show parts of input.✗ Incorrect
The
-a option with tee appends output to the file instead of overwriting it.3fill in blank
hardFix the error in the code to save output of echo Hello to greeting.txt and still show it on screen.
Linux CLI
echo Hello | [1] greeting.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cat which reads files but does not write output here.Using
echo or ls which do not split output.✗ Incorrect
Only
tee can split output to file and screen. Others do not work here.4fill in blank
hardFill both blanks to save output of ps aux to processes.txt and append output to all_processes.txt while showing on screen.
Linux CLI
ps aux | [1] processes.txt | [2] -a all_processes.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cat which does not split output.Using
grep which filters but does not write to files.✗ Incorrect
The first
tee writes to processes.txt. The second tee -a appends to all_processes.txt.5fill in blank
hardFill all three blanks to save output of find . -type f to files.txt, append to all_files.txt, and filter lines containing .txt.
Linux CLI
find . -type f | [1] files.txt | [2] -a all_files.txt | [3] '.txt'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cat which does not write output to files.Using
grep before tee which changes output flow.✗ Incorrect
First two blanks use
tee to write and append files. Last blank uses grep to filter lines.