Bash 脚本 - 递归查找新行和文件末尾的回车符
我有一个网站给我带来各种错误,我运行了一个递归脚本来检查 BOM 标头..但是我如何做同样的事情来查找文件末尾的回车符和换行符?
我想检查我的代码库以确保没有任何文件带有多余的行
I have a website that is giving me all sorts of errors, I've ran a recursive script to check for BOM headers.. but how would I do the same thing to find carriage returns and line feeds at the end of a file?
I want to check over my codebase to make sure there aren't any files with extra lines hanging out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你想检查(不删除/替换)文件末尾的空行。
您可以尝试:
如果文件末尾至少有一个空行,这将打印出文件名。
对于递归,您可以使用
find ... |xargs awk '...'
updated
好的,我做了一个示例,以便您可以测试:
上面的行将根据当前目录递归检查所有php文件,如果php文件末尾至少有一个空行,则打印文件名。
i guess you want to check (without remove/replace) the empty lines at the end of a file.
you can try :
this will print the file name out if there is at least one empty line at the end of the file.
for Recursion, you could use
find ... |xargs awk '...'
updated
ok, I made an example, so that you could test:
the above line will check all php files recursively based on your current directory, if there is at least one empty line at the end of a php file, print the filename.