findutils-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add sort option to find


From: Diego Ongaro
Subject: Re: Add sort option to find
Date: Tue, 18 Aug 2020 22:34:08 -0700

On Tue, Aug 18, 2020 at 7:11 PM Dale R. Worley <worley@alum.mit.edu> wrote:
>
> How does sorting interact with localization?  By default, I'd expect
> find -s to sort a directory the same way that ls does.

It's using strcoll internally, so it respects LC_COLLATE. With my home
directory of about 690K files, I get the same order as `/bin/ls -A` for both
LC_ALL=C and LC_ALL=en_us.UTF-8. Here's the imperfect script I used to test
that:

myfind -s ~ > find.txt
myls() {
  /bin/ls -A "$1" | while read file; do
    echo "$1/$file"
    if [ ! -h "$1/$file" ] && [ -d "$1/$file" ]; then
      myls "$1/$file"
    fi
  done
}
(echo ~; myls ~) > ls.txt
diff find.txt ls.txt

-Diego



reply via email to

[Prev in Thread] Current Thread [Next in Thread]