How to append content to a file?

0128

To append content to a file in Linux, you can use the >> operator in the command line. Here’s how you can do it:

Using the Command Line

  1. Open your terminal.

  2. Use the following command:

    echo "Your new content here" >> filename.txt

    Replace "Your new content here" with the text you want to append and filename.txt with the name of your file.

Example

If you want to append the text "Learning Bash scripting" to a file named notes.txt, you would run:

echo "Learning Bash scripting" >> notes.txt

Viewing the Updated File

To see the updated content of the file, you can use the cat command:

cat notes.txt

This will display the contents of notes.txt, including the newly appended text.

0 Comments

no data
Be the first to share your comment!