How do I append the output of a command to the end of a text 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.
Use the >> operator to append text to a file.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With