Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux `只在某些子目录中查找`_Linux_Find - Fatal编程技术网

Linux `只在某些子目录中查找`

Linux `只在某些子目录中查找`,linux,find,Linux,Find,我有这个目录结构 $ 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

我有这个目录结构

 $ 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
因此,基本上只在目录
test/test1
test/test3
中搜索
file.txt
。为了让这一切继续下去,我试过这个

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

但是它什么也不返回。

这个答案似乎对你有帮助


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

这个答案似乎可以帮助您


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

欢迎使用SO。非常感谢!对于后代来说,我最终使用的确切命令是
findtest\(-path'test/test3/*'-或-path'test/test1/*'\)-和-name file.txt
Welocome to SO。非常感谢!对于后代来说,我最终使用的确切命令是
findtest\(-path'test/test3/*'-或-path'test/test1/*'\)和-name file.txt