首页 > 解决方案 > 仅在某些子目录中查找

问题描述

我有这个目录结构

 $ tree test
test
├── test1
│   ├── test11
│   │   └── file.txt
│   ├── test12
│   │   └── file.txt
│   └── test13
│       └── file.txt
├── test2
│   └── file.txt
└── test3
    └── file.txt

6 directories, 5 files

我想要一个会返回的 find 命令

$ find test -constrain_to_paths test/test{13} -name file.txt 
test/test3/file.txt
test/test1/test11/file.txt
test/test1/test12/file.txt
test/test1/test13/file.txt

所以基本上file.txt只在目录test/test1test/test3. 为了做到这一点,我尝试了这个

$ find test \( -path './test3/*' -o -path './test2/*' \) -name file.txt

但它什么也不返回。

标签: linuxfind

解决方案


似乎这个答案可以帮助你https://unix.stackexchange.com/a/60850

例如:find test/test1 test/test3 -name file.txt


推荐阅读