How can I remove the BOM from a UTF-8 file?

后端 未结 5 1655
忘掉有多难
忘掉有多难 2020-12-06 04:53

I have a file in UTF-8 encoding with BOM and want to remove the BOM. Are there any linux command-line tools to remove the BOM from the file?

$ file test.xml
         


        
5条回答
  •  死守一世寂寞
    2020-12-06 05:28

    Joshua Pinter's answer works correctly on mac so I wrote a script that removes the BOM from all files in a given folder, see here.

    It can be used like follows:

    Remove BOM from all files in current directory: rmbom .

    Print all files with a BOM in the current directory: rmbom . -a

    Only remove BOM from all files in current directory with extension txt or cs: rmbom . -e txt -e cs

提交回复
热议问题