1000줄이 넘는 city.txt 파일(한 줄에 하나의 도시 이름)이 있고 다음 코드 블록이 포함된 format.xml 파일도 있습니다.
<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>
format.xml을 복사하고 CITY-FROM-TEXT-FILE-LINE-1을 목록의 도시 이름으로 변경하는 bash 스크립트가 필요합니다. 각 도시마다 하나의 코드 블록이 있습니다.
도와 줄수있으세요 ?
답변1
$ cat city.txt | \
while read CITY; do \
sed "s/CITY-FROM-TEXT-FILE-LINE-1/$CITY/" format.xml; \
done