Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to redirect the output of echo Hello to a file named greeting.txt, overwriting the file if it exists.
Linux CLI
echo Hello [1] greeting.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using >> appends instead of overwriting.
Using < is for input redirection, not output.
Using | pipes output to another command, not a file.
✗ Incorrect
The single greater-than symbol (>) redirects the output to a file, overwriting it if it exists.
2fill in blank
mediumComplete the code to append the output of date to a file named log.txt without deleting existing content.
Linux CLI
date [1] log.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using > overwrites the file, losing previous data.
Using < is for input, not output.
Using | sends output to another command.
✗ Incorrect
The double greater-than symbol (>>) appends output to the file, keeping existing content.
3fill in blank
hardFix the error in the command to append the output of ls to files.txt.
Linux CLI
ls [1] files.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using > overwrites the file instead of appending.
Using < is for input redirection.
Using | pipes output to another command.
✗ Incorrect
To add output to the end of a file, use >>. Using > overwrites the file.
4fill in blank
hardFill both blanks to redirect the output of echo Test to output.txt and then append date output to the same file.
Linux CLI
echo Test [1] output.txt date [2] output.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using >> for the first command overwrites nothing, just appends.
Using < is for input, not output.
Using | pipes output, not redirecting to file.
✗ Incorrect
Use > to overwrite the file first, then >> to append to it.
5fill in blank
hardFill all three blanks to create a file summary.txt with the output of uname -a, then append the output of whoami, and finally append the current date.
Linux CLI
uname -a [1] summary.txt whoami [2] summary.txt date [3] summary.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using > for all commands overwrites the file each time.
Using < is for input, not output.
Using | pipes output instead of redirecting to file.
✗ Incorrect
Use > to create or overwrite the file first, then >> to append outputs.