Shell Scripting App

Source: Internet
Author: User

Parse the scrambled log file into the temp file, then use the AWK&NBSP;1004&NBSP;&NBSP;CD&NBSP;/USR/LOCAL&NBSP;1005&NBSP;&NBSP;LL&NBSP;1006&NBSP;&NBSP;CD  pttmsg/ 1007  ll 1008  cd msgbin-2/ 1009  ll 1010   cd proxy 1011  ll 1012  cd log 1013  ll  1014  tail -1000 proxy_sub0_20160107.log  1015  grep  ' = = = Ret '  proxy_sub0_20160107.log  1016  grep  ' ===ret '  proxy_sub0_20160107.log  > test.log 1017  cat test.log  1018  grep  ' ~time '  proxy_sub0_20160107.log > test.log 1019  grep  ' ~time '  proxy_sub0_ 20160106.log > test.log 1020  tail -1000 proxy_sub0_20160107.log   1021  tail -1000 proxy_sub0_20160106.log  1022  grep  ' ~time '  proxy_sub0_20160106.log > test.log    formatting files to test.log 1023  cat test.log  first  1053  cat test.log | awk -F  ' <I> '   ' {print $2} '   1054  cat test.log | awk -f  ' <I> '   ' {print $2} '  >  ceshi.log    final formatting for required files  1055  cat ceshi.log scp -r [email protected]:/usr/local/pttmsg/msgbin-2/proxy/log/proxy_sub0_ ' date ' +%y%m%d '. Log./log/remotely copying files to the current server directory---------------------- ---------ssh_host= "[email protected]"  remote_gfile="/usr/local/pttmsg/msgbin-3/groupcall/log/gcall_sub0_${yestime}.log "# Log the temporary group chat length to the length of the user's call if ssh  $ssh _host test -e  $remote _gfile;          #判断远程服务器是否有该文件-----------------------------  #line = ' ssrc:875640674 '   #cat   $gnewfile  | grep  $line   #筛选查找   #cat   $gnewfile  | awk  '!x[$0]++ '     #去除文件中重复的数据   #cat   $gnewfile  | grep  $line  | head -1    #获取第一行数据   #cat   $gnewfile  | awk  ' End {print} '          #获取最后一行   #cat   $gnewfile  | awk -F  ': '   ' {print  $NF} '     #获取每行的最后一个数据  sql= "select count (*)  as count from vec_pt_ Useractive where time= ' $tmptime '; res=$ (mysql -h${host} -p${port} -u${dbuser} -p${dbpsw} ${dbname} -e  "${sql}")   #接收查询的结果res0 = ($res)     #转化为数组  

[email protected] programming]$ cat Facebook.txt
banana:30:5.5
apple:10:2.5
pear:90:2.3
orange:20:3.4

This file has three columns, separated by a colon between the column and column, the first column indicates the fruit type, the second column represents the fruit quantity, and the third column represents the fruit price.

So I would like to sort by the number of fruits, that is, in the second column, how to use the sort implementation?

Fortunately, sort provides the-t option, after which you can set the spacer. (Does not think of the cut and paste's-D option, resonance ~ ~)

After you specify a spacer, you can use-K to specify the number of columns

sOrt-n-K 2-t: Facebook.txt

Shell Scripting App

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.