I've been reading up on interesting Terminal commands (I've used it forever, but there's always more to learn) when I ran across this. I ran sudo fs_usage
and got a whole lot of this:
...
13:39:09 ioctl 0.000019 WindowServer
13:39:09 ioctl 0.000017 WindowServer
13:39:09 ioctl 0.000020 WindowServer
13:39:09 ioctl 0.000018 WindowServer
...
I figure, if I ever actually need to use this, it would be nice to have a way not only to filter out filesystem activity related to the WindowServer, in particular, but other processes as well. It would also be nice to specify a service or process for which to return information.
Have I misread the usefulness of this function? Is there a way to get rid of those numerous WindowServer calls? Can I specify the processes in which I'm interested?
Best Answer
All that is possible by using fs_usage with several options. You may also pipe it to grep to further restrict the output.
To exclude a process or a pid (and also fs_usage itself) use the -e option:
Specifying the -f option turns on output filtering based on the mode provided. The possible modes are:
Example:
To just show a special pid/command and exclude all other, use the pid (enter
ps aux
to get it) or the name of the command or applicationExamples:
A different possibility is to pipe the output of fs_usage to grep:
The part
grep -v grep
orgrep -v WindowsServer
excludes "grep" and/or "WindowsServer" from occurring in the result.Sources:
Apple developer
Rentzsch