LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 08: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, 10:20 PM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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, 04:14 PM   #3
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

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


Reply



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 PM.

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