Jump to content



How to Insert String into File on Linux

Linux Ubuntu CentOS Debian

  • Please log in to reply
No replies to this topic

#1 Wilson18



  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 20 April 2015 - 01:07 AM

To insert a short string into a file, you can use the echo command

echo "text" >> file.txt

To inset a longer, multi-line string, we can use the cat command. 

cat << EOF > file.txt
First line.
Second line.
Third line.

List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+

Also tagged with one or more of these keywords: Linux, Ubuntu, CentOS, Debian