Am 06.01.2021 um 19:17 schrieb Kamran via Cygwin:
Hi all
"ls" (version 8.26) sorts wrongly if given large number of files via "find" or
"xargs"
For example:
find -type f -exec ls -oS -h {} +
OR
find -type f -print0 | xargs -0r ls -oS -h
Gives following data. Sorry for the long listing, and wrapped lines. But search for
"setup.ini" which is about 17 MB, it is sorted AFTER very small files.
In fact it seams that sorting is restarted from that file (subsequent files are again sorted). Note
also that removing "-h" from "ls" command lines results in the same problem.
(output is trimmed to remove unnecessary data, i.e. perms/user/date-time, but
order is the same)
26M ./release/gcc/gcc-core/gcc-core-10.2.0-1.tar.xz
24M ./release/binutils/binutils-2.34+1git.de9c1b7cfe-1.tar.xz
[...]
108 ./release/python2/python/python-2.7.16-1.tar.xz
108 ./release/python-gobject/python-gobject-2.28.7-1.tar.xz
46 ./release/tcl-tk/tcltk/tcltk-20120206-1.tar.bz2
32 ./release/man-db/man/man-2.6.7-2.tar.xz
32 ./release/popt/popt-1.16-2.tar.xz
32 ./release/procps-ng/procps/procps-3.3.10-1.tar.xz
17M ./setup.ini
5.7M ./release/vim/vim-common/vim-common-8.2.0486-1.tar.xz
4.6M ./release/w32api-headers/w32api-headers-8.0.0-1.tar.xz
1.8M ./release/vim/vim-doc/vim-doc-8.2.0486-1.tar.xz
[...]
16K ./release/xeyes/xeyes-1.1.2-1.tar.xz
15K ./release/xf86-video-dummy/xf86-video-dummy-0.3.8-1.tar.xz
12K ./release/util-linux/libuuid1/libuuid1-2.33.1-2.tar.xz
xargs uses multiple calls to ls and find calls ls once for each matching file
so in the two mentioned cases ls will not get to see the full list and thus
can't sort all the files. This is the expected bahviour and not special to
cygwin.
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple