3 ms·
For all cli apps, the importance of cli itself can't be understated. While there are only a few cli programs available to ALL unix users (grep/ps/awk/sed/xargs/
by Aperocky 7y ago
For all cli apps, the importance of cli itself can't be understated. While there are only a few cli programs available to ALL unix users (grep/ps/awk/sed/xargs/etc), the value of the pipe are one of the defining features of CLI that amplify any program made to work in CLI.
A command I often run: `ps aex | grep $common_denominator | awk '{print $1}' | xargs kill` to deal with multiprocess testing runs demonstrate this well. The pipe character is what uniquely enabled unix shells to be the great software it is that GUI have almost no real way to replicate.
- kbr2000 7y agoAs Awk is a pattern-matching language, you can simplify it to something like this: ps aux |awk '/what/ {print "kill " $2}' This will give you a list of kill commands you can review, before piping to |sh to shake off those processes :) And when what you try to do sequentially might take too long, you can consider throwing GNU Parallel [1] in the pipemix! [1] https://en.wikipedia.org/wiki/GNU_parallel https://en.wikipedia.org/wiki/GNU_parallel
- jolmg 7y ago> ps aex | grep $common_denominator | awk '{print $1}' | xargs kill That looks pretty equivalent to: pkill -f $common_denominator I suppose this is less portable, though.