Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FWIW: find output differs from book (and appears to be expected) #22

Open
atc0005 opened this issue Jun 13, 2024 · 0 comments
Open

FWIW: find output differs from book (and appears to be expected) #22

atc0005 opened this issue Jun 13, 2024 · 0 comments

Comments

@atc0005
Copy link

atc0005 commented Jun 13, 2024

TL; DR

The output differs system to system regardless of the find implementation (BSD vs GNU) that is used.

Overview

This is less of a bug report and more of a FYI for others going through the book. No matter the version of find that I tested with the output did not match what the book shows.

Version of repo used:

$ git log -n 1
commit 10d983f68e84b9c94057da6ecf555bc419e11999 (HEAD -> main, origin/main, origin/HEAD)
Author: Ken Youens-Clark <[email protected]>
Date:   Tue Mar 19 11:35:02 2024 -0700

    readme

From the book

CH7, page 144-145 (epub) of the book notes that the BSD find output is on the left with GNU version on Linux on the right:

$ find .                          $ find .
.                                 .
./g.csv                           ./d
./a                               ./d/d.txt
./a/a.txt                         ./d/d.tsv
./a/b                             ./d/e
./a/b/b.csv                       ./d/e/e.mp3
./a/b/c                           ./d/b.csv
./a/b/c/c.mp3                     ./f
./f                               ./f/f.txt
./f/f.txt                         ./g.csv
./d                               ./a
./d/b.csv                         ./a/a.txt
./d/d.txt                         ./a/b
./d/d.tsv                         ./a/b/c
./d/e                             ./a/b/c/c.mp3
./d/e/e.mp3                       ./a/b/b.csv

Ubuntu 20.04 (WSLv2)

$ git clone https://github.com/kyclark/command-line-rust
$ cd command-line-rust/07_findr/tests/inputs
$ find .
.
./a
./a/a.txt
./a/b
./a/b/b.csv
./a/b/c
./a/b/c/c.mp3
./g.csv
./f
./f/f.txt
./d
./d/d.tsv
./d/d.txt
./d/e
./d/e/e.mp3
./d/b.csv

Ubuntu 22.04 (WSLv2)

$ git clone https://github.com/kyclark/command-line-rust
$ cd command-line-rust/07_findr/tests/inputs
$ find .
.
./g.csv
./d
./d/b.csv
./d/e
./d/e/e.mp3
./d/d.txt
./d/d.tsv
./f
./f/f.txt
./a
./a/a.txt
./a/b
./a/b/c
./a/b/c/c.mp3
./a/b/b.csv

FreeBSD 14

$ git clone https://github.com/kyclark/command-line-rust
$ cd command-line-rust/07_findr/tests/inputs
$ find .
.
./a
./a/a.txt
./a/b
./a/b/b.csv
./a/b/c
./a/b/c/c.mp3
./d
./d/b.csv
./d/d.tsv
./d/d.txt
./d/e
./d/e/e.mp3
./f
./f/f.txt
./g.csv

Thus far I've been using tools provided by a FreeBSD 14 VM as a reference for the BSD version of each tool covered by the book. Having a BSD version of the tools to contrast against the GNU version of the tools on an Ubuntu instance has been very helpful as I've gone through the exercises.

Explanation

Based on light research, the default find sort order appears to be based on the order items are stored within the directory entries. As noted in the serverfault.com Q/A below, the sort order should ordinarily be stable for the same machine but is subject to change if the filesystem entries are modified as part of maintenance operations.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant