【问题标题】:how to print certain row from specific file name that multiple appears under subdirectories如何从多个出现在子目录下的特定文件名打印某些行
【发布时间】:2022-01-20 10:06:46
【问题描述】:

我得到了以下文件系统

dir1/subDir1/index.html
dir1/subDir2/index.html
dir1/subDir3/index.html

index.hml 包含标签 [一些文本]

我想从所有 index.html 实例中打印标签行 像这样的:

dir1/subDir1/index.html -> <name>[some text]</name>
dir1/subDir2/index.html -> <name>[some text]</name>
dir1/subDir3/index.html -> <name>[some text]</name>

目前我使用 cat */index.html |grep "名称"

但我只得到没有子目录推荐的标签列表

谢谢

【问题讨论】:

  • grep "name" */index.html?
  • @KamilCuk 宾果游戏!谢谢
  • find . -name index.html -exec grep name '{}' +,或者grep name **/index.html,如果使用打开了 globstar 选项的 bash,或者 zsh。

标签: linux shell


【解决方案1】:

如果您不提供grep 文件名,他将不会打印它们。所以给它吧。

grep "name" */index.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-13
    • 2020-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-26
    • 2017-05-23
    • 1970-01-01
    相关资源
    最近更新 更多