[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Removeing N lines from a file




On Wed, 10 Feb 1999, Lance Hoffmeyer wrote:

> How can I use gawk or some other program to remove a number of lines
> from a text file.  Initially, I only need to delete the top 10 lines
> from a file but it might be useful to know how to delete lines from any
> part of the file.  The top 10 lines from each of these files vary in
> what they may contain so I need to indiscriminately delete them.  I
> figured gawk is what I would need to use to perform this task but if
> someone ones of something else that might do this that would be fine
> too.

To remove top 10 lines,
    tail -n +11
To show only top 10 lines,
    head -n 10
To show only lines [11,20],
    tail -n +11 | head -n 10


Reply to: