Bird
0
0

Which of the following is the correct syntax to append the text "Hello" to a file named greetings.txt?

easy📝 Syntax Q12 of 15
Bash Scripting - File Operations in Scripts
Which of the following is the correct syntax to append the text "Hello" to a file named greetings.txt?
Aecho Hello < greetings.txt
Becho Hello > greetings.txt
Cecho Hello >> greetings.txt
Decho Hello | greetings.txt
Step-by-Step Solution
Solution:
  1. Step 1: Identify the append operator

    To add text to the end of a file, use >> after the command.
  2. Step 2: Match syntax with the command

    echo Hello >> greetings.txt appends "Hello" to the file without deleting existing content.
  3. Final Answer:

    echo Hello >> greetings.txt -> Option C
  4. Quick Check:

    Use >> to append text [OK]
Quick Trick: Use echo text >> filename to append text [OK]
Common Mistakes:
MISTAKES
  • Using single > which overwrites the file
  • Using < which is for input redirection
  • Using pipe | incorrectly to write to file

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes