linux 查找文件的BOM头
1.查找文件BOM头,\xef\xbb\xbf是UTF8 BOM的16进制表示
[root@php-node01 wwwroot]# grep -r -I -l $'^\xEF\xBB\xBF' ./ ./v2.5/web/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 ./v2.5/web/vendor/yiisoft/yii2/messages/az/yii.php ./v2.5/wap/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 ./v2.5/wap/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/web.news_14_v5/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 ./v2.51/web.news_14_v5/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/web.service_37_v50/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/web.news_13_v5/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 ./v2.51/web.news_13_v5/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/web.service/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/web.service_36_v50/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/web.news/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 ./v2.51/web.news/vendor/yiisoft/yii2/messages/az/yii.php ./v2.51/wap/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 ./v2.51/wap/vendor/yiisoft/yii2/messages/az/yii.php
2.清除文件BOM头并检验
[root@php-node01 wwwroot]# find . -type f -exec sed -i 's/\xEF\xBB\xBF//' {} \;
[root@php-node01 wwwroot]# grep -r -I -l $'^\xEF\xBB\xBF' ./

浙公网安备 33010602011771号