Вставить строки после символа

awkподходит для такого рода форматированного ввода -форматированного вывода:

awk -F, '{printf("line starts at %d and ends at %d with value %d\n", $1, $2, $3)}' file 
line starts at 3 and ends at 3 with value 100
line starts at 4 and ends at 2 with value 50
line starts at 8 and ends at 5 with value 80
-1
19.03.2020, 18:45
3 ответа

С помощью GNUsed:

sed -E 's;<([^/]);\n<\1;2g' file

<currency>USD</currency>
<amount>111</amount>
<amountf>111/amountf>
<recv_confirms>2</recv_confirms>
<fee>22</fee>
<feef>2222</feef>
<direction>incoming</direction>
<status>1050</status>
<sent_to></sent_to>
<send_txid></send_txid>
<checkout>
<type>button</type>
<invoice>8888</invoice>
<item_name>Name - Invoice #8888</item_name>
<src_currency>USD</src_currency>
<quantity>1</quantity>
<price_per_item>25.00000000</price_per_item>
<subtotal>25.00000000</subtotal>
<total>25.00000000</total>
0
28.04.2021, 23:20

Немного sedгольфа, отступившего от @guillermochamorro, чтобы избежать разрыва первой строки

sed -E 's;([^^])(<[^/]);\1\n\2;g' file1
0
28.04.2021, 23:20

Я предлагаю использовать инструмент для создания отступов в XML-файле

xmllint -format -recover nonformatted.xml > formatted.xml
1
28.04.2021, 23:20

Теги

Похожие вопросы