Shell operations used in Baidu NLP internship for one month

Source: Internet
Author: User

The columns in the text line are broken:

Awk 'in in {srand ()} {for (I = 1; I <= NF; I ++) B [rand () NF] = $ I} end {for (X in B) printf "% s", B [x]} 'data

 

The lines in the text line are broken down:

Awk 'in in {srand ()} {B [rand () Nr] = $0} end {for (X in B) print B [x]} 'Data

Shuf-n1000 data

 

Use a.txtas the patternto search for B .txt. The actual result is the intersection of the two:

Grep-F-X-F a.txt B .txt

 

Search for B .txtbased on a.txtfor patternto display the data in a.txt. The actual difference is B-:

Grep-F-v-X-F a.txt B .txt

 

Encoding conversion:

Iconv-F gb18030-T utf8 filename

 

The Delimiter is _. The second column is key-value sorting, which is stable (unstable by default ):

Sort-T _-K1, 2-s filename

 

Sort and remove large files externally, and use the temp directory as the cache:

Sort-u-t temp filename

 

Sort filename | unique sorting record of uniq-C count-d only show duplicate record-u only show no duplicate record

 

Open the man document of awk in preview:

Man-T awk | open-a preview-F

 

Simple usage of awk and cut:

Awk-F:-V 'ofs = \ t' {print "all users are:", $1, $2, $3, $4, $5, $6, $7} '/etc/passwd | cut-F, 6

 

WC-l rows-C bytes-w words

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.