PHP :: BOM検出スクリプト

/path/to/dir 配下で BOM(Bite Order Mark) が含まれるファイルを検出するスクリプト

% cd /path/to/dir
% for f in `find . -type f`
php -r '$hex = bin2hex(file_get_contents("$argv[1]")); if(strpos($hex, "efbbbf")===0) echo $argv[1]."\n";' -- $f