Watch Files With fswatch
Monitor directories and trigger scripts from a stream of change events.
Run fswatch -o src | xargs -n1 -I{} make to rebuild when files under src change.
01Command
Command
$ fswatch -o src | xargs -n1 -I{} make02What it does
fswatch emits one line per change event, optionally collapsed with -o, so it composes naturally with xargs and shell scripts. It supports include/exclude filters with -i and -e and can monitor several directories at once.
03Risk
!Warning: Recursive watches on huge trees can exhaust file descriptors or miss events on some platforms; narrow the paths.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- Homebrew formula: fswatchEvidence: Packages fswatch, a cross-platform file change monitor that emits changed paths.
Last verified: 2026-09-22 · Category: Developer
06Related solutions
Find files larger than 500 MB on Mac
List the biggest files in your home folder that are eating disk space.
Show file extensions for all files on Mac
Make Finder display .pdf, .docx, .png and every other extension at all times.
Find Which Process Has a File or Volume Open with lsof
List every open file descriptor — files, directories, and network sockets — per process.