GNU bug report logs -
#27127
Failure in "ls -t" when parameter list is long
Previous Next
Reported by: Teppo Mäenpää <tm <at> iki.fi>
Date: Sun, 28 May 2017 22:14:03 UTC
Severity: normal
Tags: notabug
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 28/05/17 18:21, Teppo Mäenpää wrote:
> Dear all,
>
> The command "ls -t" fails to sort files as promised, when the total length of
> the names of the files to be listed (and sorted) exceeds 128 KB. All files
> are still listed, just the sorting part stops working.
>
> Man page does not mention that the sorting would work only with short file
> lists. Is this a bug? If not, what have I understood wrong?
>
> The attached script demonstrates this, in three slightly different scenarios.
> The outcome of the script is that the total lenght of filenames, given to ls
> as command line parameter, appears significant.
128K is the defafult max arg size for xargs,
so I presume you're using xargs with ls and
thus you're getting separate invocations of ls.
When commands need to operate on all files at once
(like wc and du to print totals for example)
they have the --files0-from option to take input
on stdin from xargs rather than through command arguments.
Now this option might be added to ls, though while
sorting is an operation that needs to operate on all data,
it has scalability issues best dealt with in the external sort command
(handling tmp files etc. for arbitrarily large inputs).
For example I've done this sort of ordering in the past
with the `find | sort | xargs ls` pattern, which you can see in:
http://www.pixelbeat.org/scripts/newest
cheers,
Pádraig
This bug report was last modified 8 years and 73 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.