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 somefile
l 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