rbe*_*amy 3 php shell grep sed
每个人都知道PHP讨厌文件开头或结尾的空行(在PHP标记之前或之后).
我有一个awk将修改文件的脚本.我将所有文件传递给它,事情是桃子的,没有更多的前导或尾随空行.
我想首先查找文件,以构建快速异常报告.
我试过这样的事情:
grep -r -e :a -e '/^\n*$/{$d;N;};/\n$/ba'
Run Code Online (Sandbox Code Playgroud)
但那是错的.
yha*_*ger 13
如果在每个文件的开头或结尾找到一个空行,则此shell脚本将遍历所有文件并打印:
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
Run Code Online (Sandbox Code Playgroud)
为了便于阅读,我打破了这些线条,但你也可以将它作为一个衬垫运行.
示例输出:
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2910 次 |
| 最近记录: |