普通网友 2016-01-08 10:40
浏览 72

正则表达式与inotifywait在golang中编译两种类型的文件

I use a script to auto-compile in golang with inotifywait. But this script only checks files with the extension .go. I want to also add the .tmpl extension but the script uses regular expressions. What kind of changes I have to make to this line to get the desired result?

inotifywait -q -m -r -e close_write -e moved_to --exclude '[^g][^o]$' $1

I've tried to concatenate with | or & and other things like ([^t][^m][^p][^l]|[^g][^o])$ but nothing seems to work.

  • 写回答

1条回答 默认 最新

  • dqys98341 2016-01-08 10:59
    关注

    Rather than trying to use a regex to exclude two types of file, why don't you just only watch those files?

    inotifywait -q -m -r -e close_write -e moved_to /path/**/*.{go,tmpl}
    

    To use the ** (which does a recursive match), you may have to enable bash's globstar:

    shopt -s globstar
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决