Friday, 4 February 2022

How to remove BOM Unicode character from a file (Linux)

Example of file with Byte Order Mark (BOM) bytes which appear at the beginning of the file:
 
$ xxd commands.sql
00000000: efbb bf73 656c 6563 7420 5573 6572 2066  ...select User f
00000010: 726f 6d20 6d79 7371 6c2e 7573 6572 3b    rom mysql.user;

To remove these bytes, we can use sed tool:

$ sed -i '1s/^\xef\xbb\xbf//' commands.sql 

Let's check now the file content:
 
$ xxd commands.sql
00000000: 7365 6c65 6374 2055 7365 7220 6672 6f6d  select User from
00000010: 206d 7973 716c 2e75 7365 723b             mysql.user;

1 comment:

Unknown said...

A few months ago, I felt so depressed, I got frustrated with bad credits, but then I contacted HACK VANISH by phone: +1 (747) 293-8514 and email: HACK VANISH (@) GMAIL. COM. I found out about hack vanish services through positive reviews read on some credit blogs, in a blink of an eye this great hacker restored my credit score from 509 to 784 in all 3 major credit bureaus, they got removed evictions and foreclosures, my LexisNexis and Chex system was repaired respectively, a few days later I received an email confirming the approval of my mortgage loan, it was quite surprising because I never thought it was possible. Today, I can confidently say that 2021 was a banner year for my husband and I as we now own a new house and a new SUV courtesy of HACK VANISH, I would definitely recommend him to anyone in need of a genuine Hacker.