problems with 'while read'
Willi Burmeister
wib at informatik.uni-kiel.dbp.de
Tue May 7 02:14:52 AEST 1991
Just a simple (??) question: Why does this small program not work?
------ cut here ------ cut here ------ cut here ------ cut here ------
#!/bin/sh
#
cat << EOF > hugo
one
two
three
four
EOF
while read num
do
echo "do something with <$num>"
last=$num
done < hugo
echo "last num = <$last>"
------ cut here ------ cut here ------ cut here ------ cut here ------
the output will always be:
do something with <one>
do something with <two>
do something with <three>
do something with <four>
last num = <>
What I want is:
do something with <one>
do something with <two>
do something with <three>
do something with <four>
last num = <four>
^^^^
Any help would be much appreciated.
thanks in advance
Willi
+------------------+----------------------------------------+
| Willi Burmeister | e-mail: wib at informatik.uni-kiel.dbp.de |
| Holzkrugweg 30 | phone office: +49 0431 560498 |
| D-2390 Flensburg | phone home: +49 0461 94166 |
+------------------+----------------------------------------+
More information about the Comp.unix.shell
mailing list