From b2470324e3927c5e505ff206aa6d6fe63f42a191 Mon Sep 17 00:00:00 2001 From: typebrook Date: Tue, 19 Nov 2019 21:34:34 +0800 Subject: update --- scripts/osm/osm.osc.by_member | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/osm/osm.osc.by_member (limited to 'scripts/osm/osm.osc.by_member') diff --git a/scripts/osm/osm.osc.by_member b/scripts/osm/osm.osc.by_member new file mode 100755 index 0000000..5f9d9be --- /dev/null +++ b/scripts/osm/osm.osc.by_member @@ -0,0 +1,31 @@ +#!/bin/bash + +while read -r line +do + + TYPE=$(echo $line | cut -d ' ' -f1) # field1 is type + ID=$(echo $line | cut -d ' ' -f2) # field2 is ID + + NEW_MEMBERS=$(echo $line |\ + cut -d' ' -f3- |\ + sed -r 's/([0-9]+)//g') + + echo $NEW_MEMBERS + + # print matched element with new tags to .osc file + cat $1 |\ + sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { + /<$TYPE id=\"$ID\"/ { + s/(version=\"[0-9]+\")(.*)/\1>/ + a \ \ \ \ $NEW_MEMBERS + } + p + /<\/$TYPE/ q + }" >> $1.osc +done + +# Add .osc structure for output +sed -ir '1 i + 1 i + $ a + $ a ' $1.osc -- cgit v1.2.3-70-g09d2