Shell—读取文件的每一行内容并输出
程序员文章站
2022-11-07 20:00:50
读取文件的每一行内容并输出 #!/bin/bash # 方法1 while read line do echo $line done < a.txt # 方法2 cat a.txt | while read line do echo $line done # 方法3 # for line in `c ......
读取文件的每一行内容并输出
#!/bin/bash
# 方法1
while read line
do
echo $line
done < a.txt
# 方法2
cat a.txt | while read line
do
echo $line
done
# 方法3
# for line in `cat a.txt`
for line in $(cat a.txt)
do
echo $line
done