Bird
0
0

Which of the following commands correctly appends the string "Farewell" to a file named goodbye.txt?

easy🧠 Conceptual Q2 of 15
Bash Scripting - File Operations in Scripts
Which of the following commands correctly appends the string "Farewell" to a file named goodbye.txt?
Aecho "Farewell" > goodbye.txt
Becho "Farewell" >> goodbye.txt
Cecho "Farewell" < goodbye.txt
Decho "Farewell" | goodbye.txt
Step-by-Step Solution
Solution:
  1. Step 1: Identify append syntax

    Appending text to a file uses >> to add without overwriting.
  2. Step 2: Analyze options

    echo "Farewell" >> goodbye.txt uses >> correctly; B overwrites; C and D are invalid for appending.
  3. Final Answer:

    echo "Farewell" >> goodbye.txt -> Option B
  4. Quick Check:

    Append uses double greater than [OK]
Quick Trick: Use >> to append text to files [OK]
Common Mistakes:
MISTAKES
  • Using single > which overwrites file
  • Using < which is input redirection
  • Using pipe incorrectly to redirect output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes