Hi, I am new to linux and am trying to parse a bunch of files that looks as follows -
- Some text
- start list some other text
- start sublist1
- continue sublist1
- more elements
- more elements2
- a sublist2
- a sub-sublist1
- a sublist2
- start list some other text
Where all the spaces before the list are tabs. I need a way to parse the text so that a colon is added for sublists... so that it looks like the following at the end:
- Some text:
- start list some other text:
- start sublist1
- continue sublist1
- more elements
- more elements2:
- a sublist2:
- a sub-sublist1
- a sublist2:
- another element
- start list some other text:
So colons are added only when there is a sublist available.
I tried looking into sed and awk commands but I am was unable to find anything that stored the status of the previous line to be able to add the colon at the end. It does not have to be done in sed or awk, I have been trying these though and no luck. Any suggestions at all would help.
Any help would be very much appreciated,
Thanks in advance, Jack