Recall & Review
beginner
What does the > operator do in Linux command line?
The > operator redirects the standard output (stdout) of a command to a file, overwriting the file if it already exists.
Click to reveal answer
beginner
What is the difference between > and >> in Linux stdout redirection?
The > operator overwrites the file with new output, while >> appends the output to the end of the file without deleting existing content.
Click to reveal answer
beginner
How would you save the output of the command ls to a file named list.txt, replacing any existing content?
Use the command: ls > list.txt
Click to reveal answer
beginner
How do you add the output of the command date to the end of a file named log.txt without deleting existing content?
Use the command: date >> log.txt
Click to reveal answer
beginner
Why is stdout redirection useful in scripting and automation?
It allows saving command outputs to files for later use, logging, or processing, making scripts more powerful and organized.
Click to reveal answer
What happens when you run: echo "Hello" > greetings.txt?
✗ Incorrect
The > operator redirects output to the file, overwriting it or creating it if it doesn't exist.
Which operator appends output to a file without deleting existing content?
✗ Incorrect
The >> operator appends output to the file, preserving existing content.
If you want to save the output of ls -l to a file and keep old data, which command is correct?
✗ Incorrect
Using >> appends the new output to the existing file content.
What does the command cat file.txt > output.txt do?
✗ Incorrect
The > operator overwrites output.txt with the content of file.txt.
Why might you use stdout redirection in a script?
✗ Incorrect
Redirecting stdout saves output to files, useful for logs or further processing.
Explain how > and >> differ when redirecting command output in Linux.
Think about what happens to existing file content.
You got /3 concepts.
Describe a real-life situation where you would use stdout redirection in a script.
Imagine you want to keep track of what a script does over time.
You got /3 concepts.