0
0
Linux CLIscripting~10 mins

stdout redirection (>, >>) in Linux CLI - Interactive Code Practice

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

Complete 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'
A<
B>
C>>
D|
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.
2fill in blank
medium

Complete 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'
A>
B|
C<
D>>
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.
3fill in blank
hard

Fix 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'
A|
B>
C>>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using > overwrites the file instead of appending.
Using < is for input redirection.
Using | pipes output to another command.
4fill in blank
hard

Fill 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'
A>
B>>
C<
D|
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.
5fill in blank
hard

Fill 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'
A>
B>>
C<
D|
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.