Hi,

head(1) holds the whole text when using -n -1 (or any other negative number). However, ideally, it only needs to hold the last NUM lines (in case they are the last ones).


Experiment:

$ head -n -1
1
2
3
4
5  # Here I do ^D
1
2
3
4
$


See?  It holds everything.  It could instead just do:

$ head -n -1
1
2
1
3
2
4
3
5
4  # And if I ^D here, it would just discard the line containing 5.
$


Thanks,

Alex

--
Alejandro Colomar
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

Reply via email to