Low Orbit Flux Logo 2 F

Linux How To Append To A File

In Linux, you can append text to a file like this:


echo "This is a test."  >>  my_existing_file.txt
echo "Another line of text."  >>  my_existing_file.txt

You can also redirect the output of an arbitrary command to a file like this:


ps -ef >> my_existing_file.txt

You can redirect multiple lines to a file like this.


cat >> my_existing_file.txt

After running this command you can type as many lines of input as you want. When you are done just type [CTRL]-D to stop reading. Everything entered will be appended to the file. See this example. ā€œ^Dā€ represents where we typed [CTRL]-D.


cat >> my_existing_file.txt
this is a test
this is a test3
 ^D