Linux append console output to a logfile?

36,574

Solution 1

You can use >> for appending to the same logfile for e.g cmd1 >> logfile.log then use for other commnad like

cmd2 >> logfile.log

>> is used for append data to the file

Solution 2

just replace > for >>

Solution 3

Change the operator:

command >> logfile.log

Solution 4

Use command >> logfile.log

Solution 5

A couple ways:

1) Uses io piping as follows:

$> echo 'some text' >> file.txt (will be appended)

2) Using a program like sed:

$> cat file.txt

some text

$> sed -i '$ a\ here is some more text' file.txt (will also be appended, without piping)

Gl hf!

Share:
36,574

Related videos on Youtube

Wingblade
Author by

Wingblade

Updated on November 05, 2020

Comments

  • Wingblade
    Wingblade over 3 years

    I know that I can let Linux to write the console output to a logfile by doing:

    command > logfile.log
    

    But this overwrites whatever was in the logfile before. How do I make it append the output to the logfile rather than overwriting it?