Reputation: 1144
I want a process to keep reading inputs from stdin after sending a string to it initially. How can i do it in bash?
here is a incorrect solution to explain what i am trying to do.
echo "$HEADER" | cat - < /dev/stdin
Here cat command must receive the content of $HEADER
first then behave like how cat -
should behave.
Upvotes: 0
Views: 514
Reputation: 123410
You can pipe multiple commands in sequence, where the the first writes a header and the second is just cat
to relay input from stdin to stdout:
{ echo "$HEADER"; cat; } | yourcommand
The problem with your approach is that you can only ever have one stdin, while you try to use two. echo "foo" | cat /dev/stdin /dev/tty
could have been an option, but this unnecessarily relies on having a terminal.
Upvotes: 5