Linux“查找”仅适用于当前文件夹和指定的文件夹

时间:2015-09-17 01:24:54

标签: linux recursion command-line find filesystems

我需要在当前文件夹(非递归)和其他一些文件夹(递归)中查找文件。例如,我有一个树结构,如:

  • 的folder1 /
  • 文件夹2 /
    • folder2-1 /
      • file2-1.php
  • folder3 /
    • file3-1.php
  • file1.php
  • file2.php

我想仅查找文件file1.phpfile2.phpfile2-1.php。因此,在root + folder2 /递归中搜索。

我能找到的所有资源都描述了

find . -maxdepth 1 -iname "*.php" // gives `file1.php` and `file2.php`

find folder2 -iname "*.php" // gives me `file2-1.php`

所以:

问。如何组合这些命令?

P.S。我应该能够在命令行中进一步发送找到的文件列表(例如xgettext)。

1 个答案:

答案 0 :(得分:2)

喜欢这个吗?

( find . -maxdepth 1 -iname "*.php"; find folder2 -iname "*.php") | xgettext