$ cat city.txt | \
while read CITY; do \
sed "s/CITY-FROM-TEXT-FILE-LINE-1/$CITY/" format.xml; \
done
Eu tenho um arquivo city.txt com mais de 1.000 linhas (um nome de cidade por linha) e também um arquivo format.xml com esse bloco de código:
<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>
Eu preciso de um script bash que copie format.xml e altere CITY-FROM-TEXT-FILE-LINE-1 para o nome da cidade na lista. Um bloco de código para cada cidade.
Você pode me ajudar por favor?
$ cat city.txt | \
while read CITY; do \
sed "s/CITY-FROM-TEXT-FILE-LINE-1/$CITY/" format.xml; \
done