3

I see in the documents for fswatch it has $ fswatch -0 [opts] [paths] | xargs -0 -n 1 -I {} [command] but I don't really understand how I'm supposed to add multiple paths to that - I'm watching two paths lib and test. I've tried: fswatch -r lib,test, fswatch -r lib test, and finally fswatch -r [lib test] How do I watch multiple paths with fswatch at the same time?

Jono
  • 3,393
  • 6
  • 33
  • 48

3 Answers3

4

Separate the paths with a space (i.e. ' ')

For example:

fswatch "path/one" "path/two" echo "whatever"
Alan W. Smith
  • 24,647
  • 4
  • 70
  • 96
mikhuang
  • 2,694
  • 2
  • 19
  • 17
1

The only possibility I found is to execute the fswatch command multiple times:

do_backup() {
    // what you want to do
    rsync -ahhvzPR --delete $FILE $BACKUP_DIR
}

fswatch -r lib | while read FILE; do
    do_backup
done &

fswatch -r test | while read FILE; do
    do_backup
done &

This will start the process for both directories in detached mode.

More about the detached mode can be found here.

Community
  • 1
  • 1
KittMedia
  • 7,368
  • 13
  • 34
  • 38
-1

just use "," among the multi path.