In Bash, we can add contents to file easily using the > character. Like this :
echo "myContents" > ~/myfile.txt
What if you want to append contents to the file without overwriting ? The easiest way to do this is change the “>” to “»”. Just by making this small change, appending will be done :
echo "myContents" >> ~/myfile.txt
Even if the file doesn’t exist, Bash will create one with the contents given to append.
You can also use cat to append :
cat >> ~/file.txt << EOF
This is a content that can have any type of characters
single quotes and double quotes can be included.
EOF