How to get stdout to console and pipe to next command at the same time?
I've tried using the Read command as suggested here which worked to get the output of Grep from a Tail of a log file to a variable and then to a log or email, but I'd still like to get the output to stdout console as well: https://unix.stackexchange.com/a/365222/346155
I've tried using Tee as here: https://unix.stackexchange.com/a/47936/346155
I'm using the --line-buffered flag just in case from here: https://stackoverflow.com/a/7162898/4240654
I may be missing something simple about the sdtin logic, but the case from the first link suggests that Bash may not have this simple capability. And that variables cannot read from a subshell.
The fact that
echo 'hello' | echo $(</dev/stdin) works, suggests it might be possible. Another way to look at it is, how can I stdout to console within each pipe segment. That should help to debug a long chain of commands, before committing it to a bash script.
echo 'hello' | echo $(</dev/stdin) >/dev/stout or
echo 'hello' | tee >/dev/stdout | echo 2nd $(</dev/stdin), the latter should output 'hello' twice, but only does so once.