Remove BOM from any number of files – one-liner

Removal of the BOM (byte order mark) is a common problem. For single files there are easy ways to use Notepad++ or Vi. For a large number of files in one directory you want to use another approach. Here is a useful Linux one-liner:

This iterates over all files in a directory, removes the BOM and creates a backup file for each file modified.

If you don’t need a backup file just use this one-liner:

 

 

(172 Posts)

20 years of coding and working as software engineer but I am still eager to learn more. I am very passionate when it comes to open source, Linux and Java. But I made my peace with Windows long ago to fully enjoy my PC gaming hobby. I have a soft spot for 90s electronic music and Babylon 5. In the evenings you will find me roaming the endless space in Warframe (IGN k05h).