Skip to content

Instantly share code, notes, and snippets.

@hasn-prevas
hasn-prevas / add-bom.sh
Last active May 22, 2023 02:07
Shell script to add UTF-8 BOM to any file
#!/bin/sh
BOM='\xEF\xBB\xBF'
if ! sed -n "1{/^$BOM/q1}" "$1"; then
echo "Already has BOM" >&2
exit 1
fi
sed -i "1s/^/$BOM/" "$1"