Example 1 :
#!/bin/bash
while read line
do
echo $line
done < yourfileinputpath.txt
Example 2:
#!/bin/bash
for line in `cat yourfileinputpath.txt`
do
echo $line
done
本文提供了两个使用Bash脚本读取文件的示例,包括如何逐行读取并输出文件内容的方法,适用于初学者理解Bash脚本的基本操作。
Example 1 :
#!/bin/bash
while read line
do
echo $line
done < yourfileinputpath.txt
Example 2:
#!/bin/bash
for line in `cat yourfileinputpath.txt`
do
echo $line
done
786
1万+

被折叠的 条评论
为什么被折叠?
