Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing shell script and I need to display my output at the same time however it doesn't work with 2> somefile.txt and if I do | tee -a somefilel it will not overwrite which I need to . <>

SO, i came up with ... > newfile.txt | cat newfile.txt , however doesn't work for a newfile and need to do chmod, but I have to run my script twice in order to get it work... so i need something more efficient than > newfile.txt | chmod 755 newfile.txt |cat newfile.txt...

Basically I need a shell script I need to display my output at the same time is recording to a file without overwriting, if the file was already exist ...

I hope it make sense :) Thank you

share|improve this question
Also asked on unix&linux -- please stick to one forum please. – glenn jackman Jun 16 '13 at 23:10
up vote 1 down vote accepted

Removing the -a from tee will make it overwrite instead of append.

share|improve this answer
yes, it did work. so easy :) – user231620 Jun 16 '13 at 22:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.