[NTLUG:Discuss] OT: head and tail
Fred James
fredjame at fredjame.cnc.net
Wed Mar 30 12:35:33 CST 2005
All
(Off topic (?) : head and tail)
Starting with a 23,083 line text document, and wanting to discard 131
line of the top and 5 off the bottom.
head -23078 filename | tail -22947 > newfilename
right? Wrong. The resulting file was 473 lines, but ...
head -23078 filename | tail +131 > newfilename
works as expected.
From man tail (on IRIX):
" Tails relative to the end of the file are stored in a buffer, and thus
are limited in length. Various kinds of anomalous behavior may happen
with character special files. The tail command will only tail the last
256 Kbytes of a file regardless of its line count.
"
From man tail (on SVR4 Release 4.0)
" Tails relative to the end of the file are stored in a
buffer, and thus are limited in length. Various kinds of
anomalous behavior may happen with character special files.
The tail command will only tail the last 4096 bytes of a
file regardless of its line count.
"
Similar reading on Sun
... no such item in man on Linux. But then, Linux doesn't have the
option for 'tail +n', which is the solution on the others.
I didn't know that.
Regards
Fred James
--
Compassion alone stands apart from the continuous traffic between good and evil proceeding within us. "Om Mani Padme Hum"
More information about the Discuss
mailing list