Linux– 检查文件末尾是否有换行符

Linux– 检查文件末尾是否有换行符,第1张

概述参见英文答案 > How to detect file ends in newline?                                    7个我有两个文件,一个有换行,一个没有:文件:text_without_newline$root@kali:/home#cat text_without_newline This is a Te

参见英文答案 > How to detect file ends in newline?                                    7个
我有两个文件,一个有换行,一个没有:

文件:text_without_newline

$root@kali:/home#cat text_without_newlineThis is a TestfileThis file does not contain a newline at the end$root@kali:/home#

文件:text_with_newline

$root@kali:/home#cat text_with_newlineThis is a TestfileThis file does contain a newline at the end$root@kali:/home#

是否有命令或函数来检查文件末尾是否有换行符?
我已经找到了this解决方案,但它对我不起作用. (编辑:IGnorE:使用preg_match和PHP的解决方案也可以.)最佳答案只需输入:

cat -e nameofyourfile

如果有换行符,则以$符号结尾.
如果没有,它将以%符号结束. 总结

以上是内存溢出为你收集整理的Linux – 检查文件末尾是否有换行符全部内容,希望文章能够帮你解决Linux – 检查文件末尾是否有换行符所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1047875.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存