Using exec to emulate BASIC's READ and DATA statements

Download exec-io-demo.sh

#!/bin/sh

# Demo of using exec to emulate old BASIC feature
# of READ and DATA statements.
#
# Written 4/2007 by Wayne Pollock, Tampa Florida USA

exec 3<<EndOfData
some
data
EndOfData

read line <&3
echo line 1: $line

read line <&3
echo line 2: $line

read line <&3
echo line 3: $line