In linux, convert the file to utf8-general Linux technology-Linux programming and kernel information. The following is a detailed description. The entire project needs to be converted to a multi-language version. All file storage formats are converted from gb2312 to utf8. For convenience, the following script is written using the iconv command:
CODE :#! /Bin/bash
If [-z "$1"]; Then Echo "Please input a directory name "; Exit 1; Fi
If [-z "$2"]; Then Echo "Please input a file conversion "; Exit 1; Fi
Echo-n> error. log For I in 'Find $1-name "$2 "' Do # Echo $ I If [-f $ I]; then Iconv-f gb2312-t utf8 $ I-o tmp.txt 2> error. log; If [$? -Eq 0]; Then Echo "$ I is converted successfully! " Cp tmp.txt $ I Else Echo-n "The file is $ I, 'date + '% Y-% m-% d % H: % M: % S'"> error. log Echo> error. log Fi # Echo $ I; Fi Done If [-f tmp.txt]; then Rm-f tmp.txt>/dev/null; Fi
Exit $? |