Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to append the text 'Hello' to the file named output.txt.
Bash Scripting
echo "Hello" [1] output.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which overwrites the file instead of appending.
Using '<' which is for input redirection, not output.
Using '|' which pipes output to another command.
✗ Incorrect
The '>>' operator appends the output to the file without overwriting existing content.
2fill in blank
mediumComplete the code to append the output of the command 'date' to the file log.txt.
Bash Scripting
date [1] log.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which overwrites the file.
Using '<' which is for input redirection.
Using '|' which sends output to another command.
✗ Incorrect
Using '>>' appends the output of 'date' to log.txt without erasing existing content.
3fill in blank
hardFix the error in the code to append the string 'Done' to the file results.txt.
Bash Scripting
echo Done [1] results.txt Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which overwrites the file.
Using '<' which is for input redirection.
Using '|' which pipes output to another command.
✗ Incorrect
The '>>' operator correctly appends the string to the file without overwriting.
4fill in blank
hardFill both blanks to append the output of 'ls -l' to the file directory_list.txt.
Bash Scripting
[1] [2] directory_list.txt
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which overwrites the file.
Using 'cat' instead of the listing command.
Swapping the order of command and operator.
✗ Incorrect
The command 'ls -l' lists files, and '>>' appends its output to the file.
5fill in blank
hardFill all three blanks to append the word count of file.txt to counts.log.
Bash Scripting
[1] [2] [3] counts.log
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which overwrites the file.
Swapping the file name and operator positions.
Using wrong command instead of 'wc -w'.
✗ Incorrect
The command 'wc -w file.txt' counts words, and '>>' appends the result to counts.log.