This is my first post on this site. I have probably not very easy problem with awk or sed language. In my file are data like this:
A
B
C
[Start]D
E
F
[/End]
G
...
[Start]H
I
J
[/End]
...
K
And I need following result:
A
B
C
[Open]D E F[/Close]
G
...
[Open]H I J[/Close]
...
K
For now I have not working awk code:
BEGIN {
step=0
}
/[\/End]/ {
if(step==3) print "[/Close]"
step=0
}
step==2 {
print
step=3
}
step==1{
print
step=2
}
/[Start]/ {
print "[Begin]"
step=1
}
step=0{
print
}
Many thanks for yours answers. I hope to stay here a little bit longer. Cheers! P.
This awk will do most of it, but will leave space before the [\Close]
It's easy to trim that in another pass (pipe previous output to this script)