[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
head(1): Optimize -n -NUM
From: |
Alejandro Colomar (man-pages) |
Subject: |
head(1): Optimize -n -NUM |
Date: |
Sat, 8 Jan 2022 19:32:40 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 |
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/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- head(1): Optimize -n -NUM,
Alejandro Colomar (man-pages) <=