-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Add option for natural ordering (a la -v
in ls
)
#324
Comments
as a workaround you can use |
@ErichDonGubler Thank you for your feedback. I think this is better left to external tools, as @tmccombs suggests. Another way is to use ▶ fd -0 | xargs -0 ls -1v
file-1
file-2
file-3
file-11
file-12
file-22 |
@sharkdp: I don't really have anything to add after seeing the discussion you've linked. You definitely call the shots! I wonder if there IS a case where there's significant enough gain by using internal sorting (which would NOT be the default, of course -- I agree with the opinion you expressed there in #159). Let me see if I can find some numbers that form a convincing case -- if I can't find something in the next few days, I'll happily close this. :) |
@ErichDonGubler Thank you for the feedback. I'd definitely be interesting in hearing use cases for such a feature! However, I am still following the "80% of the use cases" philosophy with |
I'm going to close this for now. Feel free to comment here and I can reopen the ticket. |
Windows user here to complain about order inconsistency between launches. Let’s say I want to compute hashes like that
|
@sergeevabc: Was there something in the documentation that gave you the impression that a certain order of output was guaranteed? AFAIK |
@ErichDonGubler, some kind of processing order is usually expected from CLI file-related utils (archivers like 7zip and Zstandard, backup managers like Duplicacy and Restic, defrag managers like Contig, duplicate killers like Jdupes, hash calculators like Rhash, even media encoders like LAME and FLAC gave me that impression). |
So, first, let me see if I can address your immediate problem by asking a question: can your environment be expected to have common POSIX tools like fd -tf -d 1 | sort -V | xargs -I {} rhash --sha256 {} In regards to Second, it's true that applications can (and often do) enforce a specific order of file walking results -- even if it is only defined by the filesystem implementation. However, not all applications or tools guarantee it, particularly those that traverse file trees asynchronously and without a cleanup nor sorting pass. To illustrate my point, let's analyze where asynchronously operations happen in the relevant paths of
I'll let @sharkdp correct me if I'm wrong here about the intent of the code, but my assumption is that it's optimized for speed: don't add another pass, keep work between file discovery and printing output as simple as possible. |
@ErichDonGubler is correct. You can use |
@sharkdp, indeed, @ErichDonGubler, your bio says ‘dedicated to building software for other humans’. Being an average human with calloused hands, I’m looking for tools that first and foremost deliver the predictable output based on the previous experience. Human-friendly tool is expected to have name and version, licenсe and author’s contact data, manual with commands explanation and usage examples. But above all its tangible visual part should resemble behaviour of other tools from the same niche (until author is some kind of revolutionary who believes that customs are obsolete or ineffective). For example, |
@sergeevabc: I see the value in having a reproducible order with the tools we're discussing here, and I'm glad you are teaching me about it! You're the first human I've encountered that has A) expressed a preference for a reliable order and B) has actually taken time to write about it. I would imagine that many humans might also not care or prefer speed to that ordering (because they may not have the same previous experience as you!) -- so I don't consider your point generally applicable, but I do think it's a valuable perspective to keep in mind. |
Add a new `-l`/`--list` option to show more details about the search results. This is basically an alias for `--exec-batch ls -l` with some additional `ls` options. This can be used in order to: * see metadata like permissions, owner, file size, modification times (#491) * see symlink targets (#482) * achieve a determinstic output order (#324, #196, #159) * avoid duplicate search results when multiple search paths are given (#405)
Add a new `-l`/`--list` option to show more details about the search results. This is basically an alias for `--exec-batch ls -l` with some additional `ls` options. This can be used in order to: * see metadata like permissions, owner, file size, modification times (#491) * see symlink targets (#482) * achieve a deterministic output order (#324, #196, #159) * avoid duplicate search results when multiple search paths are given (#405)
Add a new `-l`/`--list` option to show more details about the search results. This is basically an alias for `--exec-batch ls -l` with some additional `ls` options. This can be used in order to: * see metadata like permissions, owner, file size, modification times (#491) * see symlink targets (#482) * achieve a deterministic output order (#324, #196, #159) * avoid duplicate search results when multiple search paths are given (#405)
This is now supported (in a particular way) by the new |
This has now been released in fd v8.0. |
Hmm. Windows 7 x64, FD 9.0.0. $ fd -g *.jpg -tf -j 1 -x xxhsum {}
\879b2d9894fda9fd .\\thumbs.jpg
\44c472c9d6f50bf8 .\\DSC_6953.jpg
\9e0e685cb71d658e .\\DSC_6947.jpg
\b21dfab7d945fc8c .\\DSC_6945.jpg
\e507ebc868c72df5 .\\DSC_6943.jpg
\d13e17e56d68c251 .\\DSC_6942.jpg
\fc5313fefea68b02 .\\DSC_6923.jpg
\9e87379e55f0c7d4 .\\DSC_6907.jpg
\23703ed86e11a3e6 .\\DSC_6906.jpg
\8e8ee2a826c7e045 .\\DSC_6905.jpg
\31939f6304f099b6 .\\DSC_6904.jpg
\323f7c57871e27e6 .\\DSC_6903.jpg
\d1dfab7f948a3dc1 .\\DSC_6902.jpg
\563c70cda89a1737 .\\DSC_6901.jpg
\8d1ab1076d4b4cd7 .\\DSC_6900.jpg
\6fbfac6f39669c1b .\\DSC_6899.jpg
\b7607f0b98a92bf4 .\\DSC_6898.jpg
\73ed628cb434a733 .\\DSC_6897.jpg
\8380dc1a51b5972a .\\DSC_6896.jpg
\24fa50966a7b913c .\\DSC_6895.jpg
\46cb55b63ff71972 .\\DSC_6894.jpg However, the following output was expected $ xxhsum *.jpg
46cb55b63ff71972 DSC_6894.jpg
24fa50966a7b913c DSC_6895.jpg
8380dc1a51b5972a DSC_6896.jpg
73ed628cb434a733 DSC_6897.jpg
b7607f0b98a92bf4 DSC_6898.jpg
6fbfac6f39669c1b DSC_6899.jpg
8d1ab1076d4b4cd7 DSC_6900.jpg
563c70cda89a1737 DSC_6901.jpg
d1dfab7f948a3dc1 DSC_6902.jpg
323f7c57871e27e6 DSC_6903.jpg
31939f6304f099b6 DSC_6904.jpg
8e8ee2a826c7e045 DSC_6905.jpg
23703ed86e11a3e6 DSC_6906.jpg
9e87379e55f0c7d4 DSC_6907.jpg
fc5313fefea68b02 DSC_6923.jpg
d13e17e56d68c251 DSC_6942.jpg
e507ebc868c72df5 DSC_6943.jpg
b21dfab7d945fc8c DSC_6945.jpg
9e0e685cb71d658e DSC_6947.jpg
44c472c9d6f50bf8 DSC_6953.jpg
879b2d9894fda9fd thumbs.jpg As you can see, FD a) got it in reverse and b) added some odd slashes. |
@sergeevabc: If you consider that a bug, filing a separate issue is likely to be more fruitful than posting in a (tangentially related) resolved feature request that was originally filed ~5.5 years ago. 😉 |
Huh, I can reproduce this as well. It appears, at least for relatively small numbers of results, that if you use As for the slashes... that is very strange. fd doesn't do any transformation on the command output, so I have no idea what is causing that. |
After some more investigation it does appear that this is the result of I don't know why that is, probably the implementation uses a stack, and pulls items off of the stack. If we switched to using Note that while using Another option could be to refactor our optimistic sorting if we get results quickly for |
lt would be really, really handy for scripting to have a flag to arrange output using natural ordering.
Given the following
tree
:The output of
ls -1
/fd
is currently:The proposed output for natural order (
ls -1v
, proposed to be something likefd -v
) would be:If you need a dependency for this,
rust-natord
is small and seems like it could fit the bill.The text was updated successfully, but these errors were encountered: