awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' text.txt > ohne_BOM.txt
awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' text.txt > ohne_BOM.txt
sed -i '1 s/^\xEF\xBB\xBF//' text.txt
$str = file_get_contents('utf8_with_bom.php');
$bom = pack("CCC", 0xef, 0xbb, 0xbf);
if (0 == strncmp($str, $bom, 3)) {
echo "BOM detected - file is UTF-8\n";
$str = substr($str, 3);
}