One way is to pipe it to tee -a /dev/tty >> file
like so:
echo "This is some text" | tee -a /dev/tty >> file
Another way is to pipe it to tee -a file
with no redirects like so:
echo "This is some text" | tee -a file
A third way(if you need >>
directly after the command) is to redirect to /dev/tty
(not saved to file though) like so:
echo "This is some text" >> /dev/tty
If that is not enough, then you can use named pipes(two terminals are needed for this process) by creating a named pipe called e.g. my_pipe
in one terminal like so:
mkfifo my_pipe
Then, redirecting your output to it like so:
echo "This is some text" >> my_pipe
Then, from another terminal read that named pipe and do whatever you want with the output like so:
cat my_pipe | tee -a file
or like so(to keep the pipe waiting/open for reading between writes):
tail -F my_pipe | tee -a file
Keep in mind that paths apply to named pipes like any other file ... so make sure you provide the correct path to the named pipe when you use it.
>>
directly after the command and have the output on screen as well, which seems to be an essential part of the OP :-)>>
be essential here?>>
makes Ansible believe it was a successful operation even if it failed" is in the question anyway ... I would suggest you ask the asker :-)>>
seems to be better. (Though I think OP's somehow misunderstanding Ansible's operation here.)