linux--How to view a specific row of data in the contents of a file __linux

Source: Internet
Author: User

Thinking: Through head and tail instructions, head command to see how many lines in front, tail instructions to see how many lines behind, for example: Some log log has a lot of rows, we get his 40th line of data, the idea is to get first 40 lines with head, and then tail get the last line, So what we get is the data for line 40th.
Instructions:

Head-n 2017_08_28.log | Tail-n 1

Specific performance comparison:
Get the first 40 lines

You can see that the last line of data is "right-click Rename"
Get row 40th data

We can see that the data we've taken is consistent with previous data, and we've achieved the desired goal

Of course, if it is 1000 rows of data, we want to take 900 rows of data, you can first use tail to get the next 100 rows, and then take the first row of data, the idea is this

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.