How do you append text at the end of the file using 'sed'?

You can append text at the end of a file using sed with the a command. Here’s the syntax:

sed -i '$ a Your text here' filename.txt
  • -i option edits the file in place.
  • $ specifies the last line of the file.
  • a is the command to append text.

For example, to append "Hello, World!" to the end of example.txt, you would use:

sed -i '$ a Hello, World!' example.txt

0 Comments

no data
Be the first to share your comment!