Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a city.txt file with over 1000 lines (one city name per line) , and also a format.xml file with this code block:

        <ss:Row ss:Height ="22">
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">CITY-FROM-TEXT-FILE-LINE-1</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">CALIFORNIA</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">CA</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
        <ss:Cell>
           <ss:Data ss:Type="String">xx</ss:Data>
        </ss:Cell>
    </ss:Row>

I need a bash script that will copy format.xml and change CITY-FROM-TEXT-FILE-LINE-1 to a the city name from the list. One code block fro each city.

Can you help me please ?

share|improve this question
1  
does it have to be a bash script? – chandsie Feb 5 '12 at 18:34
    
so you want to create a bunch of ss:Rows from a city.txt file? – akira Feb 21 '12 at 15:52
$ cat city.txt | \
  while read CITY; do \
       sed "s/CITY-FROM-TEXT-FILE-LINE-1/$CITY/" format.xml; \
  done
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .