【问题标题】:Building multiple files matched by globs with a shell script使用 shell 脚本构建与 glob 匹配的多个文件
【发布时间】:2015-07-16 14:16:50
【问题描述】:

我目前正在使用 gulp(一个基于 nodejs 的实用程序)作为我的构建系统,这非常复杂。因此,无论我在哪里,我都可以将我的构建系统切换到纯 shell 脚本。我还没有找到移植方法的唯一功能之一是将多个文件与一个 glob 匹配,然后并行构建所有文件。

下面是对我的用例的更具体描述:我想将 sass 构建为 css,我用来查找根 sass 文件的 glob 是 src/*/index.{sass,scss}。然后我希望我的文件在这个目录dest/*.css 中构建和输出(其中* 代表初始搜索中匹配的任何glob)。

有没有一种简单的方法可以使用 shell 脚本来做到这一点?

【问题讨论】:

    标签: node.js shell build gulp glob


    【解决方案1】:

    含糊地说:

    #!/bin/bash
    for file in src/*/index.{sass,scss}
    do dir=$(dirname "$file")
       subdir=$(basename "$dir")
       dosomecommand with $file to dest/$subdir.css &
    done
    wait
    

    通常这种事情是通过 makefile 来完成的。

    【讨论】:

      猜你喜欢
      • 2017-11-14
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多