Удаление UTF-8 BOM из консоли

linux (debian tested)
find путь/к/лайвстриту/ -type f \( -name '*.tpl' -o -name '*.php' \) -exec sed -i '1 s/^\xef\xbb\xbf//' {} \;


freebsd (7.2 tested)
find ./ -type f \( -name '*.tpl' -o -name '*.php' \) -exec sed -i -e '1 s/^\xef\xbb\xbf//' {} \;


найти файлы с BOM
find ./ -type f \( -name '*.tpl' -o -name '*.php' \) -print0 | xargs -0r awk '/^\xEF\xBB\xBF/ {print FILENAME}{nextfile}'


sed почему-то иногда не отрабатывает, поэтому php, find, awk, xargs:
php -r "ob_start();
passthru('find ./ -type f \( -name \'*.tpl\' -o -name \'*.php\' \) -print0 | xargs -0r awk \'/^\xEF\xBB\xBF/ {print FILENAME}{nextfile}\'');
foreach(array_filter(explode(\"\n\",ob_get_clean())) as \$f){
	echo \"remove BOM from \$f...\n\";
	file_put_contents(\$f, substr(file_get_contents(\$f), 3));
};"