简体   繁体   English

使用或命令在两个目录中找到unix文件的顺序

[英]order of files unix find on two directories with or command

What is the expected order of the files if one executes the following find command on Linux: 如果在Linux上执行以下find命令,那么文件的预期顺序是什么:

mkdir /tmp/dir1 /tmp/dir2
touch /tmp/dir1/1 /tmp/dir1/2 /tmp/dir2/1 /tmp/dir2/2 /tmp/dir2/3 /tmp/dir2/0
find /tmp/dir1 /tmp/dir2 -name 1 -or -name 0 -not -name 2

/tmp/dir1/1
/tmp/dir2/1
/tmp/dir2/0

Is it supposed to always give the results back from dir1 first, then dir2, or can the results be mixed in order? 它应该始终首先从dir1返回结果,然后是dir2,还是结果可以按顺序混合?

The find command will search the directories in the order given. find命令将按给定的顺序搜索目录。 Since you said 既然你说过

find /tmp/dir1 /tmp/dir2 .....

it will always first find evrything that matches below /tmp/dir1, then /tmp/dir2. 它将始终首先找到与/ tmp / dir1匹配的evrything,然后是/ tmp / dir2。

Yet, subdirectories and files can, of course, appear in any order. 然而,子目录和文件当然可以按任何顺序出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM