0
#!/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

adaptr
  • 16,576
  • 23
  • 34
Stewie
  • 577
  • 2
  • 7
  • 17

1 Answers1

1
#!/bin/bash
read fred
echo $fred
MadHatter
  • 79,770
  • 20
  • 184
  • 232
  • I want to read multiple lines ! – Stewie Nov 01 '12 at 20:46
  • 2
    You should probably have said so, then. Do you want to read them to one variable, or many? More precision in the question will get you more functionality in the answers! – MadHatter Nov 01 '12 at 21:11
  • 2
    @Stewie `while read line ; do echo $line ; done` – ott-- Nov 02 '12 at 13:10
  • @MadHatter I had written that "What I eventually require is to read from the stdin written to by the postfix pipe" which would explain that the data will span multiple lines, but I guess it wasn't enough and I'll take care next time :) Anyway initializing as bin/bash instead of bin/sh solved it thanks – Stewie Nov 02 '12 at 13:40