I have a file with single line, that line contains just like the following sample
00200100293^30^1^bla bla ...._______To: zabell00200100293^30^3^aSub00200100293^30^4^ellaCc: Sanders,De on my desk__________00200100293^30^4^___________________________________00A00ABC0293^30^1^something___To: some text00A00ABC0293^30^3^aSub00A00ABC0293^30^4^ellaCc: __________00A00ABC0293^30^4^___________________________________
I want to spilt up in to multiple line based on 00200100293^, 00A00ABC0293^ and etc...
00200100293^,00A00ABC0293^ - These numbers could be any thing but alpha-numeric the length is always fixed 11 digits followed by '^'. Basically the output should like the following.
00200100293^30^1^bla bla ...._______To: zabell
00200100293^30^3^aSub
00200100293^30^4^ellaCc: Sanders,De on my desk__________
00200100293^30^4^___________________________________
00A00ABC0293^30^1^something___To: some text
00A00ABC0293^30^3^aSub
00A00ABC0293^30^4^ellaCc: __________
00A00ABC0293^30^4^___________________________________
Thanks, but the 00200100293^ and 00A0ABC0293^ are not the only values are in the file. it contains many different string but the length is always same with 11 digits followed by "^"
00200100293^30^1^bla bla ....To: zabell00200100293^30^3^aSub00200100293^30^4^ellaCc: Sanders,De on my desk__________00200100293^30^4^___________________________________00A0ABC0293^30^1^something___To: some text00A0ABC0293^30^3^aSub00A0ABC0293^30^4^ellaCc: __________00A0ABC0293^30^4^____________________________
...
...
etc...
output:
00200100293^30^1^bla bla ....To: zabell
00200100293^30^3^aSub
00200100293^30^4^ellaCc: Sanders,De on my desk___
00200100293^30^4^___________________________________
00A0ABC0293^30^1^something___To: some text
00A0ABC0293^30^3^aSub
00A0ABC0293^30^4^ellaCc: __________
00A0ABC0293^30^4^___________________________________
$ nawk -F^ '{for(i=1;i<=NF;i++){if(length($i)>11){printf("^%s\n%s",substr($i,1,length($i)-12),substr($i,length($i)-10,length($i)))}else{printf("^%s",$i)}}}' infile
^00200100293^30^1^bla bla ...._______To: zabel
00200100293^30^3^aSu
00200100293^30^4^ellaCc: Sanders,De on my desk_________
00200100293^30^4^___________________________________
0A00ABC0293^30^1^something___To: some text
0A00ABC0293^30^3^aSub
0A00ABC0293^30^4^ellaCc: __________
0A00ABC0293^30^4^_______________________
---------- Post updated at 05:27 AM ---------- Previous update was at 05:20 AM ----------
Thanks Kamaraj,
One more help.
Instead of returning 8 single line.. is it possible to get 2 single line for the above example.. something like.
00200100293^30^1^bla bla ....To: zabel aSu ellaCc: Sanders,De on my desk_____________________________________
0A00ABC0293^30^1^something___To: some text aSub ellaCc: _________________________________