Shell script GBK Environment Search Utf-8 Log

Source: Internet
Author: User

Method 1:

Use Linux iconv to convert the Utf-8 log to GBK encoded file, and then gbk the statistics in the environment. UTF8 () {    log_file= "/lcims/crontab_shell/outfile/lan_wlan_wo/socketmain.log141114_lan1"    LOG_FILE_TMP= "/ Lcims/crontab_shell/outfile/lan_wlan_wo/141114_lan1 "    echo" utf-8-----"        #only linux os use iconv    iconv-f Utf-8-T gb2312 $LOG _file > $LOG _file_tmp     echo "--------result" more        $LOG _file_tmp|  grep "Receive" |HEAD-4;} GBK () {    echo "GBK----"    log_file= "/lcims/crontab_shell/outfile/lan_wlan_wo/socketmain.log141114_wlan2"    Lang=zh_cn.gb18030;export LANG;    More $LOG _file|  grep "Receive" |HEAD-4;} Utf8gbk

Method 2:

In the GBK environment, the GBK string is converted to Utf-8 string, and then the utf-8 log file is searched by Utf-8 string. UTF8 () {    lang=zh_cn.utf8;export LANG;    Log_file= "/lcims/crontab_shell/outfile/lan_wlan_wo/socketmain.log141114_lan1"    LOG_FILE_TMP= "/lcims/crontab _shell/outfile/lan_wlan_wo/141114_lan1 "    echo" utf-8-----"more       $LOG _file|  grep ' perl-e ' use Encode; $a =encode ("Utf-8", Decode ("gb2312", "receive"));p rint  $a ' |head-4;} Utf8


Shell script GBK Environment Search Utf-8 Log

Related Article

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.