bug-findutils
[Top][All Lists]
Advanced

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

Re: Ensure consistent order of find output


From: James Youngman
Subject: Re: Ensure consistent order of find output
Date: Mon, 27 Jan 2020 00:16:41 +0000

On Sun, Jan 26, 2020 at 3:23 PM Peng Yu <address@hidden> wrote:
>
> Hi,
>
> I'd like to make sure the `find -printf '%P\n'` output of a directory
> (i.e., only relative paths are printed) be consistent among different
> runs as long as the file paths in the directory are the same.
>
> I can pass the `find` output to `sort`. Is it the best way to do so? Thanks.

With one tweak.   Use "LC_ALL=C sort" rather than "sort" because file
names are not text.

File names aren't text because POSIX doesn't require a file's base
name to be in the same character encoding as the base name of its
parent.   It also doesn't require the base names of two directory
entries having the same parent directory to have the same encoding,
either.

In practice these do indeed differ, since quite often different users
use different character encodings.  This even crops up occasionally in
OS installs (e.g. Debian, at one time).

Therefore there can be no character encoding which will in general
deal with any path name having more than one component, or any list of
more than one path name.

James.



reply via email to

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