Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append output to the end of a text file

Tags:

bash

shell

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

like image 330
vincy Avatar asked Jun 01 '11 20:06

vincy


People also ask

Will append to the end of the file?

Using the >> operator will append data at the end of the file, while using the > will overwrite the contents of the file if already existing.

Which command to append the text at the end of the file?

Use the >> operator to append text to a file.


1 Answers

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 
like image 128
aioobe Avatar answered Oct 14 '22 05:10

aioobe