Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Anyone know how to use xargs?

Anyone know how to use xargs?
Thread Tools
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Dec 22, 2002, 05:07 PM
 
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
Reply With Quote
Dec 22, 2002, 06:43 PM
 
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
Reply With Quote
Dec 22, 2002, 09:39 PM
 
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
Reply With Quote
Dec 22, 2002, 11:23 PM
 
% 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
Reply With Quote
Dec 23, 2002, 12:22 AM
 
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
Reply With Quote
Dec 23, 2002, 12:52 AM
 
Or simply:

killall iTunes

- Mike
     
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status: Offline
Reply With Quote
Dec 23, 2002, 03:50 AM
 
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"

     
P
Moderator
Join Date: Apr 2000
Location: Gothenburg, Sweden
Status: Offline
Reply With Quote
Dec 29, 2002, 07:33 PM
 
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...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2