Redirect output to a different text file depending source of data

I have a list of DNS servers I need to look up information on. Each of these servers has a master and a slave database. Essentially what I need to do is create two text files for each server. One with the Master view and one with the Slave view. There's 20 servers, in the end I should have 40 text files.

Below is what I'm running.

#!/bin/bash
# Script is responsible for determining which zones are in which view across the DNS platform.

#references text file that contains dns server names
for i in $(cat ddns); do

#list all zones in ddns in the master db
echo "ans_listzones channel=$i master"

#list all zones in ddns in the slave db
echo "ans_listzones channel=$i slave"

done

Thank's in advance.

Show the input you have and the output you want.

Also, useless use of backticks.

Thank's for the reference guide. I cleaned that script up, still works perfectly.

Here's an example of my input and output...

ans_listzones channel=site1-ddns01 slave
172.in-addr.arpa
164.174.in-addr.arpa
165.174.in-addr.arpa
166.174.in-addr.arpa

ans_listzones channel=site1-ddns01 master
164.174.in-addr.arpa
165.174.in-addr.arpa
181.174.in-addr.arpa
182.174.in-addr.arpa

ans_listzones channel=site2-ddns02 master
25.71.in-addr.arpa
25.71.in-addr.arpa
155.74.in-addr.arpa
156.74.in-addr.arpa

ans_listzones channel=site2-ddns02 slave
161.174.in-addr.arpa
162.174.in-addr.arpa
163.174.in-addr.arpa
164.174.in-addr.arpa

:wall:

Which is which?

Input listed below. Sorry about that.

'ans_listzones channel=site1-ddns01 slave'

The site name (site1-ddns01) is dictated by the input file.

---------- Post updated 07-17-12 at 10:10 AM ---------- Previous update was 07-16-12 at 05:38 PM ----------

I figured it out. Here's what I did...

#!/bin/bash
# Name: DNS Master Slave Zone Dump
# Purpose: Script is responsible for determining which zones are in which view across the DNS platform.

#References text file that contains server names
while read i; do

#Creates text file named after server
echo "Master" > $i.txt

#list all zones in dns in the master db and outputs to text file
echo "ans_listzones channel=$i master >> $i.txt"

#creates seperation within the file for the slave zones
echo "Slave" >> $i.txt

#list all zones in dns in the slave db outputs to text file
echo "ans_listzones channel=$i slave >> $i.txt"

#ends scirpt and directs input file
done < dns