Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-13-2007, 08:39 PM   #1
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

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>
mkzone <line2 from txtfile>

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
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,707

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

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


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 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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:19 PM.

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