To control the file on Linux, I can use inotify tools like this
#!/bin/bash # with inotify-tools installed, watch for modification of file passed as first param while inotifywait -e modify $1; do # do something here done
but how to achieve this in OSX?
If you want to associate this with a Python script, you can use Watchdog, which works with both Linux and OSX.
https://pypi.python.org/pypi/watchdog
Here's what it looks like to replace pyinotify with watchdog:
https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed
Watchdog also has a shell utility called watchmedo :
watchmedo
watchmedo shell-command \ --patterns="*.py;*.txt" \ --recursive \ --command='echo "${watch_src_path}"' \ .
Yes, you can use the FSEvents API
You can use the entr tool. Usage example:
entr
ls some_file | entr do_something
On a Mac, install via Brew: brew install entr .
brew install entr
Source: https://habr.com/ru/post/894421/More articles:the average value of the RGB color of the image - phpHow to "unflatten" Ruby Array? - arraysHow to control the centering of JButton HTML text in NetBeans? - javaGit fixed in emacs without changing window layout? - gitOneToOne relation to User model (django.contrib.auth) without cascading deletion - djangoWhy do rails ignore .bundle by default? - ruby-on-railsHow to make database lock in AppEngine (GAE)? - google-app-engineHow can I control Tomcat using jvisualvm showing visualgc? - javaCustom Wordpress Editor? - tinymcejmeter testcases that captcha can handle? - captchaAll Articles