read 读取文件内容

文件名 test28.sh 

#!/bin bash
#  reading data from a file 

count=1
cat test | while read line
do 
  echo "Line $count:$line"
  count=$[ $count + 1]
done
echo  "Finshed processing the file"

test文件内内容为:

The quick brown dog jumps over the lazy fox.
This is a test,this is only a test.

运行 sh test28.sh 

输出:

Line 1:The quick brown dog jumps over the lazy fox.
Line 2:This is a test,this is only a test.

 

posted @ 2015-09-08 11:24  todaytoday  阅读(276)  评论(0编辑  收藏  举报