Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



As 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


> 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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: