Linux Get log Specifies the number of rows in the range of content

Source: Internet
Author: User

If I want to get the "shallow years of love sleeves" to "fall into the Midgard injury to me" between the content.

1. First get the line number where they are located:

-N option to display line numbers

But sometimes grep shows "match to Binary (standard input)", indicating that the search string in a binary file matches to, do not want to match the binary file, with Grep-a.

[e-mail protected]:~#  grep-an ' Shallow years full of love sleeves ' abc |awk-f: ' {print $} '3root@ubuntu: ~# c5> Grep-an ' fall into the midgard injury to me ' ABC |cut-d:-F16

awk sets the delimiter to ":" and then prints the contents of a 1th chunk

You can also use cut to do,-D to set the delimiter,-f1 take the 1th chunk of the content

2. Use sed-n ' start line, end line P ' filename

[Email protected]:~#  sed-n ' 3,6p ' abc man: Shallow Years of love sleeve piece Fangfei into the water female: Cool Providence billow a suit into the midgard injury to me

If you are viewing a row:

[Email protected]:~#  sed-n ' 3p ' abc man: Shallow years full of love sleeves

Linux Get log Specifies the number of rows in the range of content

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.