Bash Scripting - File Operations in ScriptsWhich of the following is the correct syntax to append text to a file in bash?Aecho "Hello" < file.txtBecho "Hello" > file.txtCecho "Hello" | file.txtDecho "Hello" >> file.txtCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand redirection operators in bash'>' overwrites a file, '>>' appends to a file, '<' reads from a file, '|' pipes output.Step 2: Identify the append operatorTo add text without erasing existing content, use '>>'.Final Answer:echo "Hello" >> file.txt -> Option DQuick Check:Append text syntax = echo "text" >> file [OK]Quick Trick: Use >> to add text without erasing file content [OK]Common Mistakes:MISTAKESUsing > which overwrites the fileUsing < which is for input redirectionUsing | incorrectly as a file redirect
Master "File Operations in Scripts" in Bash Scripting9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Bash Scripting Quizzes Arrays - Indexed array declaration - Quiz 3easy Arrays - Associative arrays (declare -A) - Quiz 15hard Error Handling - Custom exit codes (exit N) - Quiz 8hard Error Handling - set -o pipefail - Quiz 15hard Functions - Function definition - Quiz 9hard String Operations - String length (${#var}) - Quiz 8hard String Operations - String prefix removal (${var#pattern}) - Quiz 10hard Text Processing in Scripts - Why scripts often process text - Quiz 14medium Text Processing in Scripts - grep in scripts - Quiz 7medium Text Processing in Scripts - Here documents (<<EOF) - Quiz 9hard