每个人都知道 PHP 讨厌在文件的开头或结尾(在 PHP 标签之前或之后)出现空行.
Everyone knows PHP hates blank lines at the beginning or end of a file (before or after the PHP tags).
我有一个 awk 脚本可以修改文件.我通过它传递了我的所有文件,一切都很好,没有更多的前导或尾随空行.
I've got an awk script that will modify the files. I pass all my files through it and things are peachy, no more leading or trailing blank lines.
我想先查找文件,以构建快速异常报告.
I'd like to FIND the files first, to build a quick exception report.
我尝试过这样的事情:
grep -r -e :a -e '/^
*$/{$d;N;};/
$/ba'
但那是错误的.
此 shell 脚本将遍历您的所有文件,并在每个文件的开头或结尾找到空行时进行打印:
This shell script will go through all your files and print if it found a blank line at the beginning or end of each file:
for f in `find . -type f`; do
for t in head tail; do
$t -1 $f |egrep '^[ ]*$' >/dev/null && echo "blank line at the $t of $f";
done;
done
为了可读性我打破了线条,但你也可以将它作为单行运行.
I broke the lines for readability, but you can run it as a one liner too.
示例输出:
blank line at the head of ./b
blank line at the tail of ./c
blank line at the head of ./d
blank line at the tail of ./d
这篇关于在 BOF 或 EOF 中查找所有带有空白或 WS 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 PHP 上启用 SOAPenable SOAP on PHP(在 PHP 上启用 SOAP)
从 PHP SOAP 服务器获取接收到的 XMLGet received XML from PHP SOAP Server(从 PHP SOAP 服务器获取接收到的 XML)
不是有效的 AllXsd 值not a valid AllXsd value(不是有效的 AllXsd 值)
PHP SoapClient:SoapFault 异常无法连接到主机PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 异常无法连接到主机)
PHP中P_SHA1算法的实现Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的实现)
将字节数组从 PHP 发送到 WCFSending a byte array from PHP to WCF(将字节数组从 PHP 发送到 WCF)