3

Take a look on the following

# more  /tmp/myscript
#!/bin/bash


echo I AM
echo BIG GUY
echo AND ALSO SMART

# bash   /tmp/myscript | tee -a >/tmp/log

why we not get the output from echo in the script to the console?

actually output redirect to the log - /tmp/log but not also to the standard output

its very strange because tee -a should redirect top log and also to stand art output

what is the right way to write to log and print to console ?

expected output

# bash   /tmp/myscript | tee -a >/tmp/log

     I AM
     BIG GUY
     AND ALSO SMART

1 Answer 1

7

That's because you use the redirection of output >. tee should do the redirection, not the shell. Try without >:

bash /tmp/myscript | tee -a /tmp/log

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .