[SunHELP] xargs ?
Nicholas Dronen
sunhelp at sunhelp.org
Tue Jan 8 09:56:37 CST 2002
On Mon, Jan 07, 2002 at 08:50:53PM -0800, wyatt at draggoo.com wrote:
> One of the best uses I've found for xargs is for killing processes:
> # ps -ef | grep baduser | awk '{print $2}' | xargs kill -TERM
Leaving aside the matter of using p(kill|grep), you
can still shorten this pipeline:
In Bourne and Korn shells:
$ kill $(ps -ef | grep '[b]aduser] | awk '{ print $2 }')
In C shell (I think -- I stay as far away from it as I can):
% kill `ps -ef | grep '[b]aduser] | awk '{ print $2 }'`
You can also use xargs like:
$ xargs [ command ] < [ input file ]
which is similar to using a pipeline because
xargs reads from stdin in both cases.
Regards,
Nicholas Dronne
More information about the SunHELP
mailing list