[Bash] Encoding Conversion, Newline Manipulation, String Replacement of File

Convert encoding of file from Big5 to UTF-8 [4], remove DOS newline in file [2], replace string big5 with UTF-8 via sed command, and append UNIX newline to end of file. [3]


echo "$1: big5 to utf-8"
iconv -f big5 -t utf-8 $1 > tmp.html
mv tmp.html $1

echo "$1: remove dos newline"
tr -d '\015' <$1 > tmp.html
mv tmp.html $1

echo "$1: html meta big5 to UTF-8"
sed 's/big5/UTF-8/' -i $1

echo "$1: append newline to end of file"
sed -i -e '$a\' $1


[1]bash read arguments - Google search
[4][Bash] Convert Files in Directory From Big5 to UTF-8