Linux Learning Note 7_ Basic command review 2 (seq sed awk)

Source: Internet
Author: User


Command usage: Displays the contents of 20 to 30 lines of the file


-------------------------------------------------

Seq

Generating sequences


SEQ >[file name] Generates a sequence of 1~100 rows:

1

2

3

...

100


Note:

The sequence starts at 1 only when the maximum value is defined above

SEQ 0 100 starts from 0, sequence order follows natural number order

Seq-1 100 starting from-1:-1 0 1 ... 100


-------------------------------------------------

Sed

Stream Editor Stream editors


Sed-n ' 20,30p ' [file name] prints 20 to 30 lines of content in a file


Note:

CENTOS6, Print command character P in citation: Sed-n ' 20,30 ' p [file name]


--------------------------------------------------

Awk

Line processor


awk ' nr>19&&nr<31 ' [file name] displays 20 to 30 rows

awk ' nr==30 ' [file name] shows line 30th


Note: ' = = ' judgment equals, ' = ' is assigned


--------------------------------------------------

Grep

Filter commands


Filter commands can also be used to filter


Extended review:

grep 20-a [file name] Filters the 20th line of the printed file and displays 20 rows after 10 lines (total 11 lines)

grep 30-b [file name] Filters the 30th line of the printed file and displays the first 10 rows of 30 rows (total 11 lines)

grep 25-c 5 [file name] filters the 55th line of the printed file and displays 5 lines (11 rows) before and after 25 lines



--------------------------------------------------

Head tail

Filter commands


Extended review:

head-30 [The results of the first 30 rows of the file name]|tail-11 print files pass through the channel to the tail command, print the end 11 lines



Linux Learning Note 7_ Basic command review 2 (seq sed awk)

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.