参见英文答案 > How to detect file ends in newline? 7个
我有两个文件,一个有换行,一个没有:
文件:text_without_newline
$root@kali:/home#cat text_without_newline
This is a Testfile
This file does not contain a newline at the end
$root@kali:/home#
文件:text_with_newline
$root@kali:/home#cat text_with_newline
This is a Testfile
This file does contain a newline at the end
$root@kali:/home#
是否有命令或函数来检查文件末尾是否有换行符?
我已经找到了this解决方案,但它对我不起作用. (编辑:IGNORE:使用preg_match和PHP的解决方案也可以.)
最佳答案
只需输入:
cat -e nameofyourfile
如果有换行符,则以$符号结尾.
如果没有,它将以%符号结束.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。