简体   繁体   中英

Monitor files added to directory for size (Bash)

I would like to monitor a directory and break another program if too small files are added. Here is my prototype:

inotifywait -r -m -e modify . | 
   while read _ _ file; do 
       if (( $(stat --printf="%s" "$file") << 36500 )); then
          echo "break"
       fi
   done

But the line with the comparison operator doesn't work. Is it impossible to combine inline execution with a math operator or have I used it incorrectly?

Bash arithmetic syntax indicates that this should be (("$(stat --printf="%s" "$file")" < 36500)) . << is sometimes used in mathematics to mean "much less than", but it's not well defined as you can imagine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM