Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

$ cat city.txt | \
  while read CITY; do \
       sed "s/CITY-FROM-TEXT-FILE-LINE-1/$CITY/" format.xml; \
  done
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.