 |
 |
Anyone know how to use xargs?
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
xargs is a variable you can use to control program input in the command line, right?
Does anyone know how to use it?
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Location: Caracas, Bolivarian Republic Of Venezuela
Status:
Offline
|
|
Originally posted by [APi]TheMan:
xargs is a variable you can use to control program input in the command line, right?
Does anyone know how to use it?
No xargs is a command -- from the manpage:
The xargs utility reads space, tab, newline and end-of-file delimited arguments from the standard input and executes the specified utility with them as arguments.
For example:
% find . -name *.pdf -print0 | xargs -0 open
will open all *.pdf files below the current directory (the -print0 and -0 flags are just to escape names containig white space)
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by kvm_mkdb:
No xargs is a command -- from the manpage:
The xargs utility reads space, tab, newline and end-of-file delimited arguments from the standard input and executes the specified utility with them as arguments.
For example:
% find . -name *.pdf -print0 | xargs -0 open
will open all *.pdf files below the current directory (the -print0 and -0 flags are just to escape names containig white space)
Right on. My bad. hehehe
I was thinking along the lines of:
% kill `ps -aux | grep iTunes`
I know this won't work because grep can't strip the line of column 2 where the PID would be. (I forgot the name of the other two grep-like programs that do that stuff.)
Anyways, I thought xargs did that kinda stuff. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2001
Status:
Offline
|
|
% kill `ps -aux | grep iTunes`
cut can cut out parts of the line. you can also use awk, perl, python, ruby, .. but that's a bit overkill.
if you are just looking to kill some named process, you can use killall
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2000
Status:
Offline
|
|
Originally posted by [APi]TheMan:
Right on. My bad. hehehe 
I was thinking along the lines of:
% kill `ps -aux | grep iTunes`
I know this won't work because grep can't strip the line of column 2 where the PID would be. (I forgot the name of the other two grep-like programs that do that stuff.)
Anyways, I thought xargs did that kinda stuff.
Nope, you're thinking of awk:
% kill `ps auxww | grep iTunes | grep -v grep | awk '{ print $2 }'`
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Nov 2001
Status:
Offline
|
|
Or simply:
killall iTunes
- Mike
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by fitter:
Nope, you're thinking of awk:
% kill `ps auxww | grep iTunes | grep -v grep | awk '{ print $2 }'`
Yeah, I knew how to do it at one point... then forgot... And upon typing my post I forgot the names of those other two awk and sed.
I've used awk '{print $2}' and similar syntax before... Thanks  Comes in handy.
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status:
Offline
|
|
Originally posted by fitter:
Nope, you're thinking of awk:
% kill `ps auxww | grep iTunes | grep -v grep | awk '{ print $2 }'`
If you're entering awk anyway, why not do the greping there as well - much faster? Oh well, it's still slower than killall - if you include the time it takes to type...
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|