【问题标题】:Bash to find files under directory and goto directory and compileBash查找目录下的文件并转到目录并编译
【发布时间】:2017-07-07 17:19:29
【问题描述】:

所有 4gl 文件都位于 dir1 下它们自己的目录中。我需要将这些 4gl 文件编译为 4ge。通常我按照这个步骤编译; cd ~/dir1/file1/ build file1.4ge # 位于此文件夹中的文件为 file1.4gl

但是如果我需要创建一个循环脚本以在 dir1 下的每个目录中找到这些 4gl 文件,然后将目录更改为首先找到该文件的目录,使用命令“build file_name.4ge”编译它,然后移动到下一个 4gl 文件。有人可以帮我吗?提前致谢。

【问题讨论】:

标签: bash


【解决方案1】:

怎么样

$ find ~/ -type f -name "*.4gl" -exec sh -c \ 'cd $(dirname $1);build $(basename $1 .4ge)' sh {} \;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    相关资源
    最近更新 更多