linux - 仅在某些子目录中查找
问题描述
我有这个目录结构
$ 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/test1
和test/test3
. 为了做到这一点,我尝试了这个
$ find test \( -path './test3/*' -o -path './test2/*' \) -name file.txt
但它什么也不返回。
解决方案
似乎这个答案可以帮助你https://unix.stackexchange.com/a/60850
例如:find test/test1 test/test3 -name file.txt
推荐阅读
- php - 使用 php 在 css 文件中搜索和替换匹配的类
- oracle - 我在哪里可以找到 Oracle SQL Developer 中的计划作业?
- postgresql - 如何在 PostgreSQL 查询中使用双美元符号 (`$$`) 格式化 LaTeX 公式?
- python - 使用python将一个单词移动到行尾
- c# - 如何使用 DI-container (Autofac) 使用参数注册服务
- javascript - 如何使用 Ckeditor 保存带有 div 和 html 属性的 HTML
- ios - 布尔返回帮助查找修复
- python - 在 Matplotlib 上看不到线,可以看到点
- java - 按数字键盘实现游戏结果输入
- php - ORA-01747 错误,使用输入更新数据库