0

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.

tink
  • 14,342
  • 4
  • 46
  • 50
CondeGil
  • 97
  • 11

1 Answers1

0

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
Tom Fenech
  • 72,334
  • 12
  • 107
  • 141