To append content to a file in Linux, you can use the >> operator in the command line. Here’s how you can do it:
Using the Command Line
-
Open your terminal.
-
Use the following command:
echo "Your new content here" >> filename.txtReplace
"Your new content here"with the text you want to append andfilename.txtwith the name of your file.
Example
If you want to append the text "Learning Bash scripting" to a file named notes.txt, you would run:
echo "Learning Bash scripting" >> notes.txt
Viewing the Updated File
To see the updated content of the file, you can use the cat command:
cat notes.txt
This will display the contents of notes.txt, including the newly appended text.
