I am using
xargs to watch for file system changes, and run commands depending on which files are changing.
fswatch prints the changed files to stdout, and
xargs <my command> consumes them from stdin.
If I use
xargs -n1, my command will run after every change. If I use
xargs -n100, my command won't run until there have been 100 changes. I'd like to batch all of the changes (arguments) that occur within 1 second.
If xargs receives 50 lines on stdin at once, I'd like xargs to pass all 50 of them to my command in a single invocation, rather than 50 separate invocations as with
xargs -n1. But if xargs only receives 1 line per minute, I don't want to wait 50 minutes before my command is invoked; I want it to be relatively interactive (i.e. ~1 second maximum, provided that xargs has received a nonzero number of arguments on stdin).
Thanks in advance!