0

I have a file input.txt, which contains several paragraphs as below:

[730480.910190] [MACSTATUSIND] ACTIND_ParseMACSTATUS:
[730480.910205] fe 0a 39 01 0a 00 51 e7 ba 9d c7 0d 00 00 00 00  ..9...Q....
[730480.910220] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ...........
[730480.910233] 00 00 00 00 00 00 00 00 00 00 xx xx xx xx xx xx  .....:bC.B.
[730480.910247] xx xx yy yy yy yy yy yy zz zz 64 34 e8 ff 00 00  ......d4...

[730480.910190] [MACSTATUSIND] ACTIND_ParseMACSTATUS:
[730480.910205] fe 0a 39 01 0a 00 51 e7 ba 9d c7 0d 00 00 00 00  ..9...Q....
[730480.910220] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ...........
[730480.910233] 00 00 00 00 00 00 00 00 00 00 aa bb cc dd ee ff .....:bC.B.
[730480.910247] gg hh ii jj kk ll mm nn oo pp 64 34 e8 ff 00 00  ......d4...

from above data, for each paragraph i want to make three columns, and then store those rows in a different/new file new.txt.

Output: new.txt

   col1    col2     col3
  -------  ----    ------
xxxxxxxx   | yyyyyy |  zzzz
aabb..gghh | ii..nn |  oopp       

Note: The above paragraph log is repeated in the file many times. All the paragraphs should have start pattern with [MACSTATUSIND] ACTIND_ParseMACSTATUS:

  • How would one know the start and end of a paragraph? – Inian Jan 8 '18 at 7:54
  • @Inian All the paragraphs should have start pattern with "[MACSTATUSIND] ACTIND_ParseMACSTATUS:" – Santosh Sahu Jan 8 '18 at 7:58
  • 1
    Update that in the question and also update a proper paragraph with real values and update a sample output of it – Inian Jan 8 '18 at 8:01
  • post the filled output, not just the empty columns – RomanPerekhrest Jan 8 '18 at 8:37
  • @RomanPerekhrest comments implemented in question – Santosh Sahu Jan 8 '18 at 9:54
0
awk 'BEGIN { print "     col1        |     col2     | col3" }
    /^\[730480.910233\] / {SA = $12 $13 $14 $15 $16 $17}
    /^\[730480.910247\] / { print SA $2 $3 " | " $4 $5 $6 $7 $8 $9 " | " $10 $11}
'  input.txt > new.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.