fswatch - Stop watching a folder for changes if a file exists (bash) -


i'm using fswatch keep track of changes directory, process stop if file exists (with wildcard). file created in alternative directory (not in tracked directory) process (which generating changes need tracked).

here's tried do:

while [[ $(shopt -s nullglob; set -- "${file_to_check}"; echo $#) -eq 1 ]];    fswatch "${path_to_the_tracked_directory}" done && echo "done" 

however, script not terminate after ${file_to_check} appears.

the complex bit in condition take care of wildcards per: bash check if file exists double bracket test , wildcards

edit:

the complex bit can simplified to:

while [ $(set -- "${path_to_the_file_to_check}"${file_to_check_with_wildcards}; echo $#) -eq 0 ];    fswatch "${path_to_the_tracked_directory}" done && echo "done" 

one solution use -1/--one-event option (https://github.com/emcrisostomo/fswatch/wiki/how-to-use-fswatch).

the code looks as:

while [ $(set -- "${path_to_the_file_to_check}"${file_to_check_with_wildcards}; echo $#) -eq 0 ];       fswatch -1 "${path_to_the_tracked_directory}" done && echo "done" 

Comments

Popular posts from this blog

javascript - Hide toolbar of pdf file opened inside iframe using firefox -

Ansible - ERROR! the field 'hosts' is required but was not set -

Copy range with conditional formatting -