2

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
5

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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