LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-06-2008, 11:28 AM   #1
adamcannon
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Rep: Reputation: 0
One argument version of xargs?


Hello all,

Say I do a cut of a text file and get this result:

$ cut -f2 foo.txt
a
b
c
d
e
f

How would I pipe that to a command that would individually execute each argument? If I use xargs, the column would be combined which works great for commands that accept multiple arguments but the command I'm trying to pipe to only accepts one at a time.

Thanks!
 
Old 02-06-2008, 11:34 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Maybe as a loop:
Code:
for i in $(cut -f2 foo.txt);
do
<some command> [option $i]
done
 
Old 02-06-2008, 11:39 AM   #3
adamcannon
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Hi bigrigdriver,

Thanks for the quick response! Although I was hoping for a one-liner, that does indeed work.

Quote:
Originally Posted by bigrigdriver View Post
Maybe as a loop:
Code:
for i in $(cut -f2 foo.txt);
do
<some command> [option $i]
done
 
Old 02-06-2008, 11:41 AM   #4
adamcannon
LQ Newbie
 
Registered: Feb 2008
Posts: 3

Original Poster
Rep: Reputation: 0
I spoke too soon. It works as one-liner as well

Quote:
Originally Posted by adamcannon View Post
Hi bigrigdriver,

Thanks for the quick response! Although I was hoping for a one-liner, that does indeed work.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
message sending failed : Error[22 ] invalid argument .....but each and every argument rakeshranjanjha Linux - Software 2 01-07-2008 11:22 PM
Xargs -i problems. Glaurung Linux - Software 2 10-25-2007 03:23 AM
`wc`, `xargs` h/w Programming 11 09-30-2007 04:22 PM
xargs yawe_frek Linux - Software 1 04-15-2007 04:26 PM
xargs question reitzell Linux - Newbie 4 07-04-2004 02:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration