I have a string which is formated as a long string (no newlines) like so:
<NAME1>ID1>CODE1a>CODE1b>><NAME2>ID2>CODE2a>CODE2b>><NAME3>ID3>CODE3a>CODE3b>>
The idea is convert this string to JSON:
{
"ID1": [
"NAME1",
"CODE1a",
"CODE1b"
],
"ID2": [
"NAME2",
"CODE2a",
"CODE2b"
],
"ID3": [
"NAME3",
"CODE3a",
"CODE3b"
]
}
The question is I need that in one comand (something like cat testfile.txt | sed "..." | tr "...")
I've tried to use sed, tr, jq, but no success, and I'm completely stuck.
Thanks in advance