Watnog
asked on
Bash: file manipulation/conversion
Dear Experts,
I hope you can help me with this manipulation of a file which needs to be re-designed so that it can be used in Graphviz.
Input file as below, chunk starts with "SCHEDULE" and ends with "END".
In between chunks there's a blank line.
In each of the chunks there is upper and lower half seperated by a ":".
In the upper part each line that start with "FOLLOWS" should come on 1 line with and preceeding "SCHEDULE", seperated with "->", double quotes are necessary...
example: "FOLLOWS FTA_BES_ACC#SBP_BE_BEG_PRE RQ.@"->"SC HEDULE FTA_BES_ACC#SBP_BE_BOOT_J2 P0"
In the lower half each line should be preceeded by the "SCHEDULE" line (the first line of the chunk)
example: "SCHEDULE FTA_BES_ACC#SBP_BE_BOOT_J2 P0"->"FTA_ BES_ACC#SB P_BE_BOOT_ J2P0"
Input file:
Please be so kind to check into, this is above my skill level.
Thanks in advance.
W.
I hope you can help me with this manipulation of a file which needs to be re-designed so that it can be used in Graphviz.
Input file as below, chunk starts with "SCHEDULE" and ends with "END".
In between chunks there's a blank line.
In each of the chunks there is upper and lower half seperated by a ":".
In the upper part each line that start with "FOLLOWS" should come on 1 line with and preceeding "SCHEDULE", seperated with "->", double quotes are necessary...
example: "FOLLOWS FTA_BES_ACC#SBP_BE_BEG_PRE
In the lower half each line should be preceeded by the "SCHEDULE" line (the first line of the chunk)
example: "SCHEDULE FTA_BES_ACC#SBP_BE_BOOT_J2
Input file:
Output file:
SCHEDULE FTA_BES_ACC#SBP_BE_BOOT_J2P0
FOLLOWS FTA_BES_ACC#SBP_BE_BEG_PRERQ.@
:
FTA_BES_ACC#SBP_BE_BOOT_J2P0
END
SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP
FOLLOWS FTA_BES_ACC#SBP_BE_BOOT_J2P0.@
:
FTA_BES_ACC#SBP_BE_CHKV2SBP_SYNC
FTA_BES_ACC#SBP_BE_CHKV2SBP_SEND
FTA_BES_ACC#SBP_BE_CHKV2SBP_LIST
END
SCHEDULE FTA_BES_ACC#SBP_BE_CHKNXCTRL
FOLLOWS FTA_BES_ACC#SBP_BE_CHKV2SBP.@
FOLLOWS FTA_BES_ACC#SBP_BE_BEG_PRERQ.@
:
FTA_BES_ACC#SBP_BE_CHKNXCTRL_MONITOR _CHECK2
FTA_BES_ACC#SBP_BE_CHKNXCTRL_MONITOR _CHECK
END
"FOLLOWS FTA_BES_ACC#SBP_BE_BEG_PRERQ.@"->"SC HEDULE FTA_BES_ACC#SBP_BE_BOOT_J2 P0"
"SCHEDULE FTA_BES_ACC#SBP_BE_BOOT_J2P0"->"FTA_ BES_ACC#SB P_BE_BOOT_ J2P0"
"FOLLOWS FTA_BES_ACC#SBP_BE_BOOT_J2P0.@"->"SC HEDULE FTA_BES_ACC#SBP_BE_CHKV2SB P"
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP"->"FTA_B ES_ACC#SBP _BE_CHKV2S BP_SYNC"
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP"->"FTA_B ES_ACC#SBP _BE_CHKV2S BP_SEND"
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP"->"FTA_B ES_ACC#SBP _BE_CHKV2S BP_LIST"
"FOLLOWS FTA_BES_ACC#SBP_BE_CHKV2SBP.@"->"SCH EDULE FTA_BES_ACC#SBP_BE_CHKNXCT RL"
"FOLLOWS FTA_BES_ACC#SBP_BE_BEG_PRERQ.@"->"SC HEDULE FTA_BES_ACC#SBP_BE_CHKNXCT RL"
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKNXCTRL"->"FTA_ BES_ACC#SB P_BE_CHKNX CTRL_MONIT OR_CHECK2"
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKNXCTRL"->"FTA_ BES_ACC#SB P_BE_CHKNX CTRL_MONIT OR_CHECK"
Please be so kind to check into, this is above my skill level.
Thanks in advance.
W.
ASKER
Looks very good Noci.
Let me check things out further and I'll get back to you (my CET tomorrow).
Thanks and cheers.
W
Let me check things out further and I'll get back to you (my CET tomorrow).
Thanks and cheers.
W
ASKER
Hi Noci.
What you gave me works fine, thank you for that.
However it is slightly more complicated...
Below an example where there's a FOLLOWS also in the lower part of the chunk.
The chunk is different in these lines:
FTA_BES_ACC#SBP_BE_CHKV2SB P_SEND
FOLLOWS SBP_BE_CHKV2SBP_LIST
The idea remains the same: follows is on left side of the arrow but the FOLLOW is ommited:
"FTA_BES_ACC#SBP_BE_CHKV2S BP_LIST"-> "FTA_BES_A CC#SBP_BE_ CHKV2SBP_S END"
A secondary thing is that in the lower part the "FTA_BES_ACC#" is omitted too.
It would be great if you could have that added: it is same as the first part of the SCHEDULE name.
Final result:
I hope this makes sense and that you can find some time to do your magic again.
Cheers.
What you gave me works fine, thank you for that.
However it is slightly more complicated...
Below an example where there's a FOLLOWS also in the lower part of the chunk.
SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP
FOLLOWS FTA_BES_ACC#SBP_BE_BOOT_J2P0
:
FTA_BES_ACC#SBP_BE_CHKV2SBP_SYNC
FTA_BES_ACC#SBP_BE_CHKV2SBP_SEND
FOLLOWS SBP_BE_CHKV2SBP_LIST
FTA_BES_ACC#SBP_BE_CHKV2SBP_LIST
END
The chunk is different in these lines:
FTA_BES_ACC#SBP_BE_CHKV2SB
FOLLOWS SBP_BE_CHKV2SBP_LIST
The idea remains the same: follows is on left side of the arrow but the FOLLOW is ommited:
"FTA_BES_ACC#SBP_BE_CHKV2S
A secondary thing is that in the lower part the "FTA_BES_ACC#" is omitted too.
It would be great if you could have that added: it is same as the first part of the SCHEDULE name.
Final result:
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP"->"FTA_B ES_ACC#SBP _BE_CHKV2S BP_SYNC"
"FTA_BES_ACC#SBP_BE_CHKV2SBP_LIST"-> "FTA_BES_A CC#SBP_BE_ CHKV2SBP_S END"
"SCHEDULE FTA_BES_ACC#SBP_BE_CHKV2SBP"->"FTA_B ES_ACC#SBP _BE_CHKV2S BP_LIST"
I hope this makes sense and that you can find some time to do your magic again.
Cheers.
Is this a constant: "FTA_BES_ACC#" ? or should it come from a some identifyable line...
This is an illogical extention... because it is TRAILING the info it is used on... not impossible....
This is an illogical extention... because it is TRAILING the info it is used on... not impossible....
ASKER
The info is ommited in the input meaning that it is the same as in the line above...
equals
FTA_BES_ACC#SBP_BE_CHKV2SBP_SEND
FOLLOWS SBP_BE_CHKV2SBP_LIST
FOLLOWS SBP_BE_CHKV2SBP_LIST
equals
FTA_BES_ACC#SBP_BE_CHKV2SBP_SEND
FOLLOWS FTA_BES_ACC#SBP_BE_CHKV2SBP_LIST
FOLLOWS FTA_BES_ACC#SBP_BE_CHKV2SBP_LIST
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great Noci, it does exactly what I need...
I attach output after been processed by Graphviz.
It should miss the schedule but refer to the job it "follows" instead, and I left out input that worked fine already.
Thanks a bunch. I couldn't have come up with this, far from.
Cheers and have a good weekend.
W
sample.jpg
I attach output after been processed by Graphviz.
It should miss the schedule but refer to the job it "follows" instead, and I left out input that worked fine already.
Thanks a bunch. I couldn't have come up with this, far from.
Cheers and have a good weekend.
W
sample.jpg
ASKER
Thanks for your responsiveness and efficient help.
and run
Open in new window
Open in new window