Linux – 检查文件末尾是否有换行符
发布时间:2020-12-14 01:51:55 所属栏目:Linux 来源:网络整理
导读:参见英文答案 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 n
参见英文答案 >
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# 是否有命令或函数来检查文件末尾是否有换行符? 解决方法
只需输入:
cat -e nameofyourfile 如果有换行符,则以$符号结尾.如果没有,它将以%符号结束. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |