blank_sam
blank_sam

Reputation: 25

Inotifywait exclude all except specific files

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 ?

Upvotes: 0

Views: 1706

Answers (1)

chepner
chepner

Reputation: 532398

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 ...

Upvotes: 3

Related Questions