From 83b965342c274aa6672a508c95ce08c0e82403d8 Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 17 Nov 2019 21:51:17 +0800 Subject: update --- scripts/osm/osm.osc.create | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'scripts/osm/osm.osc.create') diff --git a/scripts/osm/osm.osc.create b/scripts/osm/osm.osc.create index 61a4dfb..c9bdaa8 100755 --- a/scripts/osm/osm.osc.create +++ b/scripts/osm/osm.osc.create @@ -1,17 +1,29 @@ - while read -r line - do - array=( $(echo $line) ) +#!/bin/bash - cat $1 |\ - sed -nr " - /<$array[1] id=$array[2]/,/<\/$array[1]/ { - /<$array[1] id=$array[2]/ a \ \ \ \ - /> $1.osc - done +while read -r line +do + TYPE=$(echo $line | cut -d ' ' -f1) + ID=$(echo $line | cut -d ' ' -f2) + NEW_TAGS=$(echo $line |\ + cut -d' ' -f3- | xargs -n2 echo |\ + sed -r 's/^([^ ]+) (.+)//' |\ + paste -s) - sed -ir '1 i - 1 i - $ a - $ a ' $1.osc + TAG_PATTERN=$(echo $line |\ + cut -d' ' -f3- | xargs -n2 echo |\ + cut -d' ' -f1 | paste -s -d'|') + + echo $TAG_PATTERN > /dev/tty + + cat $1 |\ + sed -nr "/<$TYPE id=\"$ID\"/,/<\/$TYPE/ { + /<$TYPE id=\"$ID\"/ a \ \ \ \ $NEW_TAGS + /> $1.osc +done + +sed -ir '1 i + 1 i + $ a + $ a ' $1.osc -- cgit v1.2.3-70-g09d2