So I know you can exclude files from being watched but what about the other way ? What if I only want to watch *.txt only ?
Just pass the names you want to watch as arguments:
intotifywait ... *.txt
If you are concerned the pattern will match too many files to fit on the command line, you can use the --fromfile
arguments to read the list of files to monitor from a file. The file needs to contain the actual file names, not a pattern, so you might need to create the file with something like
for f in *.txt; do printf '%s\n' "$f"; done > files.txt
inotifywait --fromfile files.txt ...