0%

bash里如何循环读取文件

  Bash操作简单,可以处理简单的计算等。有些时候会遇到文件的读取问题,那如何对文件进行循环逐行读取呢?

  这样就可以了:

1
2
3
4
5
while read -r line
do
array=(${line///})
echo ${array[1]}
done < the_file
有疑问或建议请发邮件到junxie01@gmail.com。