I want to run 2 commands on a piped-in input and want to print (to stdout) the output of both.
Each command is a combination of grep, sed and awk.
Both these commands must reside in a single .sh file.
Sample commands:
cat mult_comm.sh
sed 's/World/Boy/g'|grep Boy ; grep World
# Input
cat input.log
Hello World
# This command HAS to work EXACTLY like this
cat input.log | bash mult_comm.sh
Expected output
Hello Boy
Hello World
Actual output
Hello Boy
I tried using tee
cat mult_comm.sh
tee >(sed 's/World/Boy/g'|grep Boy) | grep World
But this gives only
Hello World
I can modify the .sh file as I want but the piped command can't be changed. Any ideas?
This is similar to OS X / Linux: pipe into two processes? and Pipe output to two different commands, but I can't figure out how to use named pipes inside the script.