Linux 'find' 仅针对当前文件夹和指定文件夹

标签 linux recursion command-line find filesystems

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

  • 文件夹1/
  • 文件夹2/
    • 文件夹2-1/
      • 文件2-1.php
  • 文件夹3/
    • file3-1.php
  • 文件1.php
  • 文件2.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`

所以:

问。如何组合这些命令?

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

最佳答案

像这样?

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

关于Linux 'find' 仅针对当前文件夹和指定文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32621218/

相关文章:

java - 深度图导致堆栈溢出 : non-recursive serialization options?

Java - 在 Windows 7 中通过命令行获取外部进程的 PID

java - Android 语音调用桌面

linux - 如何使用 Inkscape 将带有汉字的 SVG 导出为 PNG?

python - 向下传递参数的递归函数

c - 在c中尝试遍历的输出似乎不正确

php - 无法在 Windows xampp 中使用命令行导入任何 sql 文件

xcode - 在 Xcode 下进入应用程序运行

linux - grep linux 中的模式(重复/出现超过 n)

python - django 时间不能正常工作