Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Unix find command's default ordering?

Tags:

shell

unix

I was searching through the man pages for find for clues of UNIX find command default ordering.

Appreciate if anyone knows this.

http://unixhelp.ed.ac.uk/CGI/man-cgi?find

like image 767
Oh Chin Boon Avatar asked Jan 01 '26 01:01

Oh Chin Boon


2 Answers

find just peeks the files and subdirectories as they appear in the directories, just like ls -U when this option is available.

like image 191
jlliagre Avatar answered Jan 03 '26 04:01

jlliagre


The find command uses the opendir() function to get listings in a directory, which returns a directory stream, and it traverses the stream and evaluates each entry. The ones that matches criteria are returned in the order they are evaluated. Therefore, the order you get from the find command is how the underlying filesystem presents them.

like image 27
Jon Lin Avatar answered Jan 03 '26 03:01

Jon Lin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!