bash - How to capture the event of changing a file in a folder? -


will there event generated when contents of folder in unix changed(removed, added or edited), , can event captured trigger script?

if you're using linux, can use inotify subsystem catch sort thing. there inotify bindings python, perl, , forth, or can use inotifywait program (part of inotify-tools package) in shell scripts.

for example, if run inotifywait -m /tmp, watch /tmp changes. if create file, see:

/tmp/ create foo /tmp/ open foo /tmp/ attrib foo /tmp/ close_write,close foo 

and if delete file, see:

/tmp/ delete foo 

you can write shell script reads these notifications inotifywait , acts on them accordingly.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -