0

How do I specify file extensions to be monitored when using inotifywait ?

Given this code

cd "tmp"
inotifywait -me close_write --format %f . | while read file
do  rclone move "$file" …
done

Where to add the file extensions in the code? I tried replacing

--format %f .

with

--format %f *.tmp,*.tmp2 

But still doesnt work as intended

Community
  • 1
  • 1

1 Answers1

0
cd tmp
inotifywait -m . -e close_write -e moved_from | # -m is --monitor, -e is --event, what you need
while read path action file; do
 if [[ "$file" =~ .*txt$ ]]; then # if suffix is '.txt'
  echo ${path}${file} ': '${action}
  rclone moveto $file remote:dir/$file
  echo 'Continue watching...'
 fi
done