Bash "Experte" gesucht

Robert rlanghammer at web.de
Di Apr 11 14:41:35 CEST 2017


ups hab die Nummerierung übersehen.

NR zählt die Zeilen und beginnt bei 1, darum -1

awk '/add_neighbour/ {print
"<neighbour_"NR-1"><originator>"$5"</originator><nexthop>"$5"</nexthop><outgoing_interface>"$7"</outgoing_interface></neighbour_"NR-1">"}'


Am 11.04.2017 um 14:30 schrieb Robert:
> Hi,
>
> sowas sollte tun:
>
> echo "<babel_neighbour>"
>
> echo dump |nc ::1 33123 | awk '/add neighbour/ {print
> "<neighbour_0><originator>"$5"</originator><nexthop>"$5"</nexthop><outgoing_interface>"$7"</outgoing_interface></neighbour_0>"}'
>
> ungetestet!
>
> Robert
> Am 11.04.2017 um 12:39 schrieb Christian Dresel:
>> Hi
>>
>> ich hab aktuell wenig Zeit und brauch für sowas immer 2hecho "<babel_neighbour>"
>> echo dump |nc ::1 33123| awk '/add neighbour/ {print "<neighbour_0><originator>"$6 }' googlen und
>> probieren. Ich hab mal gute Hoffnung das es jemand schnell aus den
>> Stehgreif besser und schneller hinbekommt und mir kurz helfen kann ;)
>>
>> Folgende Ausgabe:
>>
>> root at NeunhofGateway:~# echo dump |nc ::1 33123|grep "add neighbour"
>> add neighbour 102aaf20 address fe80::6666:b3ff:fede:f5cd if eth0.4 reach
>> ffff rxcost 96 txcost 96 cost 96
>> add neighbour 102aaed0 address fe80::c11:12:15:da5 if fffgwcd1VPN reach
>> ffff rxcost 60000 txcost 60000 rtt 20.672 rttcost 12 cost 60012
>> root at NeunhofGateway:~#
>>
>> sollte folgendes in eine Variable schreiben:
>>
>> <babel_neighbour>
>> <neighbour_0><originator>fe80::6666:b3ff:fede:f5cd</originator><nexthop>fe80::6666:b3ff:fede:f5cd</nexthop><outgoing_interface>eth0.4</outgoing_interface></neighbour_0>
>> <neighbour_1><originator>fe80::c11:12:15:da5</originator><nexthop>fe80::c11:12:15:da5</nexthop><outgoing_interface>fffgwcd1VPN</outgoing_interface></neighbour_1>
>> </babel_neighbour>
>>
>> wenn es mehr als 2 Zeilen sind einfach mit <neighbour_2> usw. weiter
>> machen (und bei einer Zeile halt nur eine).
>>
>> Wäre super wenn mir das jemand eben zusammen basteln könnte der in Bash
>> fit drauf ist ;)
>>
>> mfg
>>
>> Christian
>>
>>
>>
>
>
>


-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 819 bytes
Beschreibung: OpenPGP digital signature
URL         : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20170411/e7e6500a/attachment.sig>


Mehr Informationen über die Mailingliste franken-dev