On Tue, Jul 07, 2009 at 09:01:02AM -0700, Bob McGowan wrote: > Alex Samad wrote: > > Hi > > > > does find out put files in any sort order ? > > > > for example > > > > for x in $(seq -w 00 99); do touch $x ii$x aa$x; done && find ii* [0-9]* > > aa* > > > > is the output guaranteed to be in sort order, i.e. ii* files first and > > sorted and then [0-9]* files next and sorted and then aa* files and > > sorted > > > > > > Alex > > > > Hi, Alex, > > The short answer is "no". > > A bit longer ;) ... > > The 'find' command reads the directory data (filename/inode ...) in the > order it was created. It prints the data as found. This is the vitial bit of information that makes senses, explains why my example looks sorted and also explains why I see it not sorted some times > > Actually, 'ls' reads the same as 'find', but 'ls' does an internal sort > before printing it. You can use '-f' or '-U' with 'ls' to "not sort" or > to "list entries in directory order" (quotes from the 'ls' man page). > > And more ;) to see just what this means: > > Run these commands, then compare the output: > > ls -U > /tmp/ls-U.txt > > find . -maxdepth 1|sed -e '/^\.\/\./d' -e 's/^\.\///'>/tmp/find_out.txt > > You need to massage the 'find' output to 1) eliminate the 'dot' files; > 2) to remove the leading './' 'find' prepends to create the path name. > > Do a diff between the files. The only difference you'll find is the > file "..", which the 'ls' command keeps. Since 'find' is recursive, it > has to ignore the '..', else it would climb up the tree, not just down, > and infinitely. > -- "We want to develop defenses that are capable of defending ourselves and defenses capable of defending others." - George W. Bush 03/29/2001 Washington, DC White House press conference,
Attachment:
signature.asc
Description: Digital signature