【问题标题】:How to list down the full paths to all files in multiple directories of a certain file format?如何列出某种文件格式的多个目录中所有文件的完整路径?
【发布时间】:2018-11-15 21:59:45
【问题描述】:

我正在寻找 Bash 解决方案来解决我的困境。我有目录project,其中有project/Batch1 project/Batch2 project/Batch3 等等。

在每个 Batch 文件夹中,我都有混合文件,但我感兴趣的是 .txt 格式的文件,例如。我可以使用ls -LR 命令递归地获取project 目录中每个文件的名称。但是,我应该如何获得包括文件名在内的完整路径,并且也仅限于 .txt 文件?

谢谢!

【问题讨论】:

标签: linux file path directory ls


【解决方案1】:

使用find 命令。打开man 1 find 并检查上述任务所需的可能选项。

这是一个简单的例子。打开终端并运行

find pwd -type f -name "*.txt"

或者

find pwd -name "*.txt"

或者你也可以使用 bash 脚本来做同样的事情。

【讨论】:

  • 谢谢!正是我需要的,只需在pwd 中添加反引号即可。
猜你喜欢
  • 1970-01-01
  • 2019-10-30
  • 2014-06-27
  • 1970-01-01
  • 2020-11-09
  • 1970-01-01
  • 2012-05-08
  • 2011-11-23
相关资源
最近更新 更多