LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-13-2007, 09:39 PM   #1
jon_k
Member
 
Registered: Jul 2003
Location: Fort Worth, Texas
Distribution: Mepis Linux 2004
Posts: 547

Rep: Reputation: 30
Using xargs to process file from list?


I've got a file full of domains in the format of

domain.com
domain2.com
domain3.com

I need to run the following command for each line

mkzone <domain> <ip>

Is there any way I could use xargs to execute mkzone <line1 from txtfile> 192.168.0.2
mkzone <line2 from txtfile> 192.168.0.2

for each line in my text file?

I figure I could it with xargs, maybe a for in file loop in bash. I'm not sure for either way.

Any ideas?
 
Old 01-13-2007, 11:20 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
With a POSIX compliant shell (like ksh or bash):
Code:
for domain in $(<file_full_of_domains)
do
  mkzone $domain 192.168.0.2
done
 
Old 01-14-2007, 05:14 PM   #3
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
Code:
cat test | xargs -I {} mkzone "{}" 192.168.0.2
 
  


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
task_struct process list helpmeforlinux Linux - General 2 01-24-2007 05:30 AM
process list true_atlantis Linux - Software 2 09-16-2006 09:50 PM
File name expansion with {} in gnu find and xargs anamericanjoe Linux - Software 2 09-16-2006 04:31 PM
List Connections by Process? juanbobo Linux - Networking 3 05-31-2006 12:07 AM
copying files and give new unique names to each file by using xargs command gnim66 Programming 6 06-22-2005 09:29 PM


All times are GMT -5. The time now is 08:52 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration