庆典:通过txt文件行迭代无法读取最后一行 [英] bash: iterating through txt file lines can't read last line

查看:165
本文介绍了庆典:通过txt文件行迭代无法读取最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而读磷;做结果
  回声$ P 结果
  完成< file.txt的

这code可以阅读file.txt的所有行除最后一行的任何想法,为什么。
谢谢

this code can read all lines in the file.txt except the last line any ideas why. Thanks

推荐答案

如果您选择在大约疑问,最后一个 \\ n 文件中,你可以试试:

if youre in doubt about the last \n in the file, you can try:

while read p; do
echo $p
done < <(grep '' file.txt)

的grep是不挑剔的行结束)

grep is not picky about the line endings ;)

您可以使用的grep。 file.txt的逃课空行...

you can use grep . file.txt for skipping empty lines...

这篇关于庆典:通过txt文件行迭代无法读取最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆