How to parse output from diskutil activity in bash script

bashdiskutil

I want to be able to run a bash script over each line output from diskutil activity", I haven't been able to figure out how to do this though.

I thought maybe I could simply:
diskutil activity | xargs bash myScript.sh

I have a feeling that xargs is just going to wait until diskutil activity is finished talking, which it will never do until you end the process.

Any suggestions on how I can execute a script per line of output would be appreciated!

Cheers!

Best Answer

The delay is probably due to buffering.

Try xargs -L 1 bash myScript.sh if you can process the data line by line.