Find extra space / new line after a closing ?> (php tag)

后端 未结 9 1683
醉话见心
醉话见心 2020-12-17 18:04

So I have a space/new line after a closing ?> (php tag) that is breaking my application.

How can I find it easily I have 1000 of files and 100000 lin

9条回答
  •  -上瘾入骨i
    2020-12-17 18:42

    use perl;

    perl -0777 -i -pe 's/\s*$//s' *.php
    
    • -0777 will slurp he whole file (-0 will be ok too)
    • -i - inplace editing, so the file will be replaces with the result
    • -p print lines
    • -e perl expression

    s/\s*$//s - treat all lines as a single line and substitute any space at the end to nothing

提交回复
热议问题