str="abcdefg"
while read line 
do
    echo $line
    str=$line
done < ./text
echo "---------------------------"
echo "Str: ${str}"

参考:http://www.manongjc.com/detail/24-atyzbjpcqhnttys.html