Character set for converting files under Linux Platform

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.