word-diff pstree

One thing I mentioned before was the worded diff pstree.

Here is what I use:


touch /tmp/pstree.old

First we want to remove some common daemons from the output that we aren’t interested in. Threads are also not very interesting, so everything with [{...}] should be removed. This could leave some lines with just line characters so those should be removed too.
Finally the diff uses -m0 (apparently it’s faster), -1 for just {+new things+} remove it to see [-removed stuff-] too, and -W to ignore all the whitespace used in pstree -U.
And -w ‘(-’ and -x ‘-)’ are more useful to tell them apart from [ ] which are used for grouping similar named processes in pstree.

pstree -U | grep -v $'agetty\nudevd\natd\ncron\ndbus\ndhcp\nexplorer\ngconf\nservices\nsyslog' | sed 's/[0-9*─]\+\[{[^}]\+}\]//g;/^[^a-zA-Z]*$/d' > /tmp/pstree.new
dwdiff -m0 -w '(-' -x '-)' -W '[] ─┬└│├1234567890*[]{}
' /tmp/pstree.old /tmp/pstree.new

Finally
mv /tmp/pstree.new /tmp/pstree.old

BTW about colorizing in the watch script, to use it on [ and ] you just need to make sure [ is the first one.
colorize='s/\[/&/g;s/[]`>)}]/&/g;s/|/&/g;s/{/&/g;s/</&/g;s/(/&/g'

Screenshot: (window 3)
screenshot_bash_sysmon

This entry was posted in Programming. Bookmark the permalink.