I am stuck for quite sometime now. Below is a line in my file -
GS|ED|001075|001081|20110626|1806|100803|X|004010ST|130|100803001
This line occurs only once and it is the second line.
I have to break this line into two lines from ST (bold) such that it looks like -
GS|ED|001075|001081|20110626|1806|100803|X|004010
ST|130|100803001
I have been trying pattern matching techniques using sed and awk but in vain till now. Would appreciate if someone can help me out. I am using bash shell.
---------- Post updated at 03:29 PM ---------- Previous update was at 03:19 PM ----------
I used awk because the system is very minimal and requesting nawk would take 2-3 days. The file contains numerous records and this is the second line which gotta be split into second and third line. I am trying to achieve like below where Intermediate_2 is the filename containing records:-
sed '2p' Intermediate_2 | awk '{gsub("ST",RS "&")}1'
OR
sed '/GS/p' Intermediate_2 | awk '{gsub("ST",RS "&")}1'
As you would know, placing this in my script produces duplicates of the split-up lines. If I use above sed(s) with -n option, then only the split lines are printed and the other contents goes away.