Linux command file content positioning: sed, uniq command

Source: Internet
Author: User
SED command

1, sed-n ' 2 ' p file

Prints only the second line of file files.

2, Sed-n ' 1,4 ' p file

Only the records from the first row to the fourth line are printed.

3, Sed-n '/los/' p file

Prints a row that matches Los.

4, Sed-n ' 4,/los/' p file

Prints all rows from line fourth to match Los.

5. sed ' d ' file

Delete all the first and second lines.

Uniq command

1. uniq-c file

The number of occurrences of repeated rows that are printed immediately.

2. uniq-d file

Only duplicate rows are printed.

3. awk ' {print $} '/var/log/httpd/access_log|sort|uniq-c

All the access IP of the Apache website is counted, and the number of statistics is printed.

Linux command file content positioning: sed, uniq command

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.