224

These are commands I type in the terminal

echo -e "First Line" | tee ~/output.log
echo -e "Second Line" | tee ~/output.log

When I look in the file output.log I only see 'Second Line'. How can I make sure that tee appends (rather than wipes out the file)?

I'd like to be able to see this in the file:

First Line
Second Line

Should I be approaching this another way?

Nakilon
  • 113
Bluebeep
  • 2,401

1 Answers1

335
echo -e "First Line" | tee ~/output.log
echo -e "Second Line" | tee -a ~/output.log
                            ^^

From man tee:

   Copy standard input to each FILE, and also to standard output.

   -a, --append
          append to the given FILEs, do not overwrite

Note: Using -a still creates the file mentioned.

Tom S
  • 1
user4556274
  • 5,097