Adding UTF-8 BOM from the command line

Shell script to add UTF-8 BOM to any file

#!/bin/bash

file=$1

cat $file > $file".temp"
printf "\xEF\xBB\xBF" > $file
cat $file".temp" >> $file
rm $file".temp"