文件名 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.

 

相关文章:

  • 2022-12-23
  • 2022-02-07
  • 2021-12-22
  • 2021-07-22
  • 2022-01-07
  • 2021-12-06
  • 2021-09-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-03
  • 2021-06-01
  • 2021-05-18
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案