Due to some reasons, we often encounter the Linux server is garbled under the problem, this is because the client, the server, the file character set encoding inconsistency caused by, here we say how to convert the character set of the file.
The character set of the converted file can use the command:
Iconv-f {pre-converted character Set}-t {converted character Set} Inputfile-o outputfile
Note that if you do not specify the-o parameter, then iconv prints the file only on the plane, but does not change the character set property of the original file.
For example: We need to convert a file from Utf-8 to GB18030 with the following command:
Iconv-f utf-8-T gb18030 a.txt-o b.txt
Of course, you can also write to a new file by redirecting
Iconv-f utf-8-T gb18030 a.txt > B.txt
You can also combine the ls-l command to generate a script for batch conversion files, as follows:
Ls-lrt|awk ' {print ' iconv-f utf-8-T GB18030 "$9"-O "$9". New "} '
You can also convert directly by using the Find command in conjunction with Xargs or-exec.
This article is from the "Database Road" blog, make sure to keep this source http://dbaway.blog.51cto.com/7099215/1688792
Character set for converting files under Linux Platform