How to efficiently delete the last line or lines of a dozens of G text file under Linux

Source: Internet
Author: User

When we log or text data on the server side, sometimes there is a need to delete the last few lines of a large file, then how to efficiently implement.

Internet browsing finally found the DD command, pro-test as follows, delete a 32GB log file the last 100 lines only need 4 minutes


[[Email protected]_10 tmp]# dd Of=sqq_jobs_run.log.bak seek=1 bs=$ (($ (stat-c%s sqq_jobs_run.log.bak)-$ (tail-1 sqq_jobs _RUN.LOG.BAK|WC-C)))

Sqq_jobs_run.log.bak to manipulate the large file, Tail-n #n代表要删掉最后的几行, here is the last line to delete.

How to efficiently delete the last line or lines of a dozens of G text file under Linux

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.