How to append output to the end of a text file

vincy picture vincy · Jun 1, 2011 · Viewed 597.7k times · Source

How do I append the output of a command to the end of a text file?

Answer

aioobe picture aioobe · Jun 1, 2011

Use >> instead of > when directing output to a file:

your_command >> file_to_append_to

If file_to_append_to does not exist, it will be created.

Example:

$ echo "hello" > file
$ echo "world" >> file
$ cat file 
hello
world