Linux 'find' 仅适用于当前文件夹和指定文件夹
Linux 'find' only for current folder and specified ones
我需要在当前文件夹(非递归)和其他一些文件夹(递归)中查找文件。例如我有一个像这样的树结构:
- 文件夹1/
- 文件夹2/
- 文件夹2-1/
- file2-1.php
- 文件夹3/
- file3-1.php
- 文件1.php
- file2.php
我只想查找文件 file1.php
、file2.php
和 file2-1.php
。所以,在根目录+folder2/递归搜索。
我能找到的所有资源都描述了
find . -maxdepth 1 -iname "*.php" // gives `file1.php` and `file2.php`
或
find folder2 -iname "*.php" // gives me `file2-1.php`
所以:
问.如何组合这些命令?
P.S。我也应该能够在命令行中进一步发送找到的文件列表(例如发送到 xgettext)。
像这样?
( find . -maxdepth 1 -iname "*.php"; find folder2 -iname "*.php") | xgettext
我需要在当前文件夹(非递归)和其他一些文件夹(递归)中查找文件。例如我有一个像这样的树结构:
- 文件夹1/
- 文件夹2/
- 文件夹2-1/
- file2-1.php
- 文件夹2-1/
- 文件夹3/
- file3-1.php
- 文件1.php
- file2.php
我只想查找文件 file1.php
、file2.php
和 file2-1.php
。所以,在根目录+folder2/递归搜索。
我能找到的所有资源都描述了
find . -maxdepth 1 -iname "*.php" // gives `file1.php` and `file2.php`
或
find folder2 -iname "*.php" // gives me `file2-1.php`
所以:
问.如何组合这些命令?
P.S。我也应该能够在命令行中进一步发送找到的文件列表(例如发送到 xgettext)。
像这样?
( find . -maxdepth 1 -iname "*.php"; find folder2 -iname "*.php") | xgettext