I am trying to read the full stdin in a variable:
script.sh
input=""
while read line
do
echo "$line"
input="$input""\n""$line"
done < /dev/stdin
echo "$input" > /tmp/test
When I run, ls | ./script.shor basically any other commands, it works fine.
However, it does not work, when I start cat | ./script.sh, enter my message, and then press Ctrl-C to exit cat.
Any ideas?
source
share