代码:

#!/bin/bash

echo 方法1
while read line
do
    echo $line;
done < testdata

echo ""
echo 方法2
cat testdata | while read line
do
    echo $line
done

echo ""
echo 方法3
oldIFS=${IFS};
IFS=$'\n';
for line in $(cat testdata)
do
    echo $line
done
IFS=${oldIFS};

 

文件 testdata:

abc
def
df ab cd
asas

相关文章:

  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2021-05-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-06
  • 2021-12-26
  • 2021-12-13
  • 2021-05-07
  • 2022-01-08
相关资源
相似解决方案