How to view file changes on Mac OSX using FSWatch?

I am trying to use fswatch to translate the following lines from a linux bash script to be able to run this on Mac OSX:

inotifywait -r -m 'myfolder/' | while read MODFILE
do
    echo "something"
done

Since inotifywait does not work on Mac OSX, I want to replace the first line of fswatch . Although README links to the fswatch man page, it does not provide a link to it, and an Internet search does not give me anything. So I tried to play a little.

I created a folder called testfswatch/, and I tried to execute the following commands in the parent folder, and then add and modify the files in the folder testfswatch/:

fswatch -o testfswatch/ | echo "LALA"
fswatch -o testfswatch/ | someSimpleProgram
fswatch -o testfswatch/ | xargs -n1 -I{} echo "LALA"
fswatch -o testfswatch/ | xargs -n1 -I{} ./someExecutable
fswatch -o testfswatch/ | xargs -n1 echo "LALA"
fswatch -o testfswatch/ | xargs -n1 someExecutable
// And more variations of the above

None of these commands do anything if I modify or add files to a folder tesfswatch/.

- , ? !

+4
2

pre-1.0 fswatch , 1.0 . , 1.0. , , .

+2

Bushmills, fswatch v. >= 1.x , fsw: , UNIX.

, (-0), fswatch : -0, fswatch , NUL (\0) ( , find xargs do).

, , ( ):

$ fswatch -0 [opts] [paths] | xargs -0 -n 1 -I {} [command]

:

  • fswatch -0 NUL.
  • xargs -0 NUL. fswatch.
  • xargs -n 1 command . x, xargs -n x.
  • xargs -I {} {} command parsed. , .

, .

+10

Source: https://habr.com/ru/post/1547161/


All Articles