Skip to content

Instantly share code, notes, and snippets.

@hacolab
Created August 3, 2019 10:05
Show Gist options
  • Save hacolab/08def4a39a608836d550695f650dd7e5 to your computer and use it in GitHub Desktop.
Save hacolab/08def4a39a608836d550695f650dd7e5 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Line fiead symbol
LF_CHAR=">"
#[INPUT]
# <entry>
# <tag>value1</tag>
# </entry>
# <entry>
# <tag>value2</tag>
# </entry>
#
#[OUTPUT]
# <entry><tag>value1</tag></entry>
# <entry><tag>value2</tag></entry>
tr '>' '<' \
| sed "s#</entry<#$LF_CHAR#g" \
| tr -d '\n' \
| tr "$LF_CHAR" '\n' \
| sed 's#<\([^<]*\)<#<\1>#g' \
| sed 's#$#</entry>#'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment