LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Using xargs to process file from list? (https://www.linuxquestions.org/questions/programming-9/using-xargs-to-process-file-from-list-519068/)

jon_k 01-13-2007 08:39 PM

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?

jlliagre 01-13-2007 10:20 PM

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


uselpa 01-14-2007 04:14 PM

Code:

cat test | xargs -I {} mkzone "{}" 192.168.0.2


All times are GMT -5. The time now is 08:26 AM.