Common shell commands

Source: Internet
Author: User

Tag: grep hex BSP df-h color directory encountered sort

1. Find the contents of the file (e.g. account number: zh123456): Grep;ls
Mode 1 Find all Files: grep zh123456 *
Mode 2 recursive lookup: ls | Xargs grep zh123456
Mode 3 Recursive lookup: Find. -name ' apf44_zswmpay* ' |xargs grep applog|awk-f ": ' {print $} ' |sort |uniq-c
2. Find out if there is a file in your directory (for example, if you want to find 20170914xzh.txt): find
2.1 Way 1 Fuzzy match lookup: find. -name "*20160106/*xzh.txt"
2.1 Way 2 Recursive lookup: Find. -name ' apf44_zswmpay* ' |xargs grep applog|awk-f ": ' {print $} ' |sort |uniq-c
3. Packaging and Unpacking command: Tar
3.1. Packaging: Tar Cvf/back/baklog/int44-log20170914.tar.gz/app/int44/log
3.2. Unpacking: Tar Xzvf/back/baklog/int44-log20170914.tar.gz/app/int44/log
4. Find out if the account number in the file is non-numeric (as an example of a problem encountered at Work Zhongshan Telecom batch file format check): awk
4.1 Check the account for non-numeric presence: awk ' BEGIN {fs= ' \004 ';} nr>1 {print NR ":" $ file.name |grep-e "[^0-9|:]+]
4.2 Count the 5th column amount and: awk ' BEGIN {fs= ' |; Total=0} nr>1 {total=total+$5} end{printf "total:%.2f\n", total} ' 20170914.txt
5. View usage space: DF;d u
5.1 Way 1:DF-HL
5.2 Way 2:DU-SM * | Sort-n//Statistics current directory size and size sorting
6. Character set conversion and hexadecimal display text: Iconv,od,xxd,stat
6.1:iconv-f utf-8-T GBK 20170630.txt//Convert files from Utf-8 to GBK on screen display
6.2:od-x 20170630.txt//hexadecimal display of text content, the first 3 bytes for the encoding type (different operating systems, the display is not the same)
6.3:xxd 20170630.txt//Displays text content in hexadecimal and displays the encoding and the original
6.4:stat 20170630.txt//View the last access time of the file, last modified time

Common shell commands

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.