Linux Bash: Append and Prepend Strings to Files

I want to append the string “BYE” to the file test.txt

echo “BYE” >> test.txt

Now, I want to prepend the string “HI” to the file test.txt

echo "HI"|cat - test.txt > /tmp/out && mv /tmp/out test.txt
This entry was posted in Linux Command Line. Bookmark the permalink.

Leave a Reply