Created
January 3, 2011 00:50
-
-
Save qsun/762980 to your computer and use it in GitHub Desktop.
remove BOM (byte order mark) FEFF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MD5=md5 | |
function usage() | |
{ | |
echo bom_removal.sh file | |
} | |
function remove_bom | |
{ | |
filename=$1 | |
echo backup $filename | |
mv $filename ${filename}.bak | |
dd if=${filename}.bak of=${filename} bs=3 skip=1 | |
} | |
if [ ! -f "$0" ]; then | |
usage | |
exit 1 | |
fi | |
filename=$1 | |
echo check if $filename is BOM | |
bom=`dd if=$filename bs=3 count=1 2>/dev/null| MD5` | |
dd if=$filename bs=3 count=1 2>/dev/null| MD5 | |
dd if=$filename bs=3 count=1 2>/dev/null| hexdump | |
if [ "$bom" = "ecaa88f7fa0bf610a5a26cf545dcd3aa" ]; then | |
remove_bom $filename | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment