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?
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
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!
A single greater than character >
WRITES output to a file.
A double character >>
APPENDS output into an existing file