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

Re: Removeing N lines from a file



Lance Hoffmeyer <lanceh@ibm.net> writes:

> 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.

Well, someone already mentioned sed, but why not just do:
tail +11 < infile > outfile

(The "+" tells tail to start printing things at line 11; to get the
last 11 lines you'd use "tail -11")

For similarly removing the end of a file, see "head".


Reply to: