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