0
0
Bash Scriptingscripting~10 mins

File descriptors and redirection in Bash Scripting - 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 standard output to a file named output.txt.

Bash Scripting
echo "Hello World" [1] output.txt
Drag options to blanks, or click blank then click option'
A>>
B2>
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using >> appends instead of overwriting.
Using < redirects input, not output.
2fill in blank
medium

Complete the code to append standard output to a file named log.txt.

Bash Scripting
ls -l [1] log.txt
Drag options to blanks, or click blank then click option'
A>
B>>
C2>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using > overwrites the file instead of appending.
Using 2> redirects standard error, not standard output.
3fill in blank
hard

Fix the error in the code to redirect standard error to errors.log.

Bash Scripting
grep 'pattern' file.txt [1] errors.log
Drag options to blanks, or click blank then click option'
A2>
B>
C>>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using > redirects standard output, not error.
Using < redirects input, not error output.
4fill in blank
hard

Fill both blanks to redirect standard output to out.txt and standard error to err.txt.

Bash Scripting
command [1] out.txt [2] err.txt
Drag options to blanks, or click blank then click option'
A>
B2>
C>>
D2>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using append operators >> or 2>> when overwriting is needed.
Mixing up standard output and error redirection operators.
5fill in blank
hard

Fill all three blanks to redirect standard output to output.log, standard error to error.log, and append standard output to combined.log.

Bash Scripting
my_script.sh [1] output.log [2] error.log [3] combined.log
Drag options to blanks, or click blank then click option'
A>
B2>
C>>
D2>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2>> for standard error when overwriting is needed.
Confusing append and overwrite operators.