Bash – reading stdin in shell

bashpipeshellstdin

#!/bin/sh
#myVar=`date`#case 1
#myVar=`cat /dev/stdin`#case 2
myVar=($(< /dev/stdin)) #case 3
echo $myVar
exit 2

case 1 works
case 2 and 3 don't work.
When I test with either 2 or 3; there is no output and the script never exits

What I eventually require is to read from the stdin written to by the postfix pipe

Best Answer

#!/bin/bash
read fred
echo $fred