From: Frank-Ulrich Sommer <f-u.s@gmx.net>
To: cygwin@cygwin.com
Subject: Re: "ls" sorts wrongly if given large number of files
Date: Wed, 6 Jan 2021 19:41:56 +0100 [thread overview]
Message-ID: <fc02f42c-ae7d-997f-b652-de9ffe243329@gmx.net> (raw)
In-Reply-To: <DB8P191MB06363D09B9C9E54A289AAB7AB4D00@DB8P191MB0636.EURP191.PROD.OUTLOOK.COM>
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.
next prev parent reply other threads:[~2021-01-06 18:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 18:17 Kamran
2021-01-06 18:41 ` Frank-Ulrich Sommer [this message]
2021-01-06 18:45 ` Brian Inglis
2021-01-06 18:45 ` Eliot Moss
2021-01-06 19:43 ` Hans-Bernhard Bröker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc02f42c-ae7d-997f-b652-de9ffe243329@gmx.net \
--to=f-u.s@gmx.net \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).