Is there a way to
tail a document and get the reverse output; because you don't know how many lines there are in a document?
I.e. I just want to get everything but the first 2 lines of
foo.txt to append to another document.
You can use this to strip the first two lines:
and this to strip the last two lines:
(assuming the file ends with
Just like standard use of
In the case
|show 1 more comment|
If you want all but the first N-1 lines, call
There's no easy, portable way to skip the last N lines. GNU
Portably, you can use an awk filter (untested):
If you want to remove the last few lines from a large file, you can determine the byte offset of the piece to truncate then perform the truncation with
You can't truncate a file in place at the beginning, though if you need to remove the first few lines of a huge file, you can move the contents around.
Thus, the following should append all but the first 2 lines of
To remove the first n lines GNU sed can be used. For example if n = 2
that will show line 3,4,5,7. More power come from use of regular expressions instead of addresses.
The limitation is that the lines numbers must be known in advance.