Bash script, watch folder, execute command

后端 未结 12 1320
小鲜肉
小鲜肉 2020-12-04 08:57

I am trying to create a bash script with 2 parameters:

  • a directory
  • a command.

I want to watch the

12条回答
  •  -上瘾入骨i
    2020-12-04 09:07

    Here's an example of watching a folder for changes and running a the less compiler when one is updated. As a prereq you need npm and these the module onchange. The node community has a whole bunch of different watch commands (like onchange) I'm not aware of any that are compiled self-contained binaries.

    npm install less onchange -g
    

    Then you can use something like:

    onchange "./stylesheets/*.less" -- lessc main.less > main.css
    

    I prefer a BASH command over the Grunt answer I gave a while back.

提交回复
热议问题