shell-逐行读取文件
Posted 刨根问底_liang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell-逐行读取文件相关的知识,希望对你有一定的参考价值。
代码:
#!/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
以上是关于shell-逐行读取文件的主要内容,如果未能解决你的问题,请参考以下文章