shell 按行读取

写法一:
#!/bin/bash
while read line
do
      echo $line     #这里可根据实际用途变化
done < urfile
 

写法二:

#!/bin/bash

cat urfile | while read line
do
    echo $line
done

注意:以上代码中urfile 为被读取的文件

猜你喜欢

转载自foreversunyao.iteye.com/blog/852229