<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Test.kmz</name>
<Placemark>
<name>Test</name>
<LookAt>
<longitude>48.7893522149238</longitude>
<latitude>35.11072013511394</latitude>
<altitude>0</altitude>
<heading>-0.1257146222858709</heading>
<tilt>27.02159138599089</tilt>
<range>804.546845381412</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<styleUrl>#m_ylw-pushpin160</styleUrl>
<Point>
<gx:drawOrder>1</gx:drawOrder>
<coordinates>48.78741496263481,35.11017636516465,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
48.78741496263481,35.11017636516465
KML에서 (역순으로) 추출 하고 싶습니다 35.11017636516465,48.78741496263481
. 이것이 sed 또는 awk의 작업입니까?
미리 감사드립니다.
답변1
AWK 사용:
awk -F '[>,]' '/coordinates/ {print $3","$2}' file
- 패턴을 찾아보세요동등 어구세 번째 필드와 두 번째 필드를 인쇄합니다.
답변2
awk -F"[<>]" '/longitude/{long=$3}/latitude/{print $3","long}' file.txt