fix UTF-8 files with BOM

If you want just to show BOM files, use this one:

grep -rl $’\xEF\xBB\xBF’ .

to remove BOM:
find . -type f -exec sed ‘1s/^\xEF\xBB\xBF//’ -i.bak {} \; -exec rm {}.bak \;
or
find -type f -print0 | xargs -0 grep -l `printf ‘^\xef\xbb\xbf’` | sed ‘s/^/found BOM in: /’

Leave a Reply

Your email address will not be published. Required fields are marked *