echo to file bash code example
Example 1: echo to file bash
echo "I am \"Finding\" difficult to write this to file" > file.txt
echo "I can \"write\" without double quotes" >> file.txt
echo "This is a test to write $PATH in my file" >> file.txt
echo 'This is a test to write '"$PATH"' in my file' >> file.txt
tee -a file.txt <<EOF
I am "Finding" difficult to write this to file
I can "write" without double quotes
EOF
Example 2: how to echo to a file in linux
echo "something" >> file
Example 3: bash string to file
echo -e "<string-to-append>" >> <file-to-append-to>
echo -e "Hello there, new line!" >> RandomWorld.txt
"Hello there,\n new line!"