Linux encoding conversion arbitrary encoding conversion Universal conversion A batch conversion script when unable to confirm source encoding

Source: Internet
Author: User

Reprint Please specify source: http://www.cnblogs.com/blazer/p/7808639.html

A more general method, all the system has been encoded, all the conversion, from the results to filter the encoding you need.

If you execute: SH test.sh t1.csv, the T1.csv.head.result file will be generated and you need to filter the required encoding from there.

Execute command:

SH test.sh $fileName

Script file:

if ["$ = =" "];then    echo" Usage:sh shell \ $fileName "    echo" please input \ $fileName "    exit 0fifilename=$1he Ad-n 1 $fileName > $fileName headfor A In ' Iconv--list | Sed ' s/\/\/$//' | Sort '; Do    iconv-f $a-t UTF-8 $fileName. head >/dev/null    if ["$?" = "0"]    ; Then        echo $a >> $fileName. Head.result        iconv-f $a-t UTF-8 $fileName. Head >> $fileName. head.result< C8/>fidone

Save content to test.sh

Linux encoding conversion arbitrary encoding conversion Universal conversion A batch conversion script when unable to confirm source encoding

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.