Remove multiple BOMs from a file
See also: Using awk to remove the Byte-order mark
To remove multiple BOMs from anywhere within a text file you can try something similar. Just leave out the ^
anchor:
perl -e 's/\xef\xbb\xbf//;' -pi~ file.js
(This edits the file in-place. But creates a backup file.js~
.)
I normally do it using vim
:
vim -c "set nobomb" -c wq! myfile