Shell awk Combat

Source: Internet
Author: User

First, the text processing

1. Extract key word frequency times by row (for example, 5th column)

awk ' begin{fs= ' | '} {a[$5]+=1;} END {for (i in a) print I ":" A[i];} ' Opt. Forumlogicnewserver_action_20161107.log | SORT-NRK 2-t ': '

2, log users per minute traffic statistics

Here we count the traffic per minute arrival rate for the "getthreadlist" interface in the log.

awk ' begin{fs= ' | '} $5== "Getthreadlist" {a[substr ($1,0,16)]+=1;} End{for (i in a) print I "\ T" a[i]} ' OPT. Forumlogicnewserver_action_20161107.log | Sort > GetThreadList.txt

3. Find all the binaries in a directory

LS-LRT | awk ' {print $9} ' | Xargs File | grep ELF | awk ' {print '} ' | Tr-d ': '

4, grep ' 2016-11-21 22:05 ' MTT. Idcenterserver_idcenterserver_20161121.log | grep ' UserInfo ' | awk ' begin{fs= ' | '} {print $6} ' | Uniq | Wc-l

Shell awk Combat

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.