I have a specific application database-file like this:
    •r           vbc.vvc          lin             K$³ñ123456    Œ  Œ      P  
                        P       P                          ;šÉÿ                                                    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ           ÿÿÿÿ                              Œ    ÿÿÿÿ          Œ       P   T  X  
      Œ                P   999999999 ëu   q0 …ª¤        ;šÉÿOverLimitLog     ÿÿ  06/27/2013  00:05:55 RS_A1_6         hijitso            183.49 OverLow         ÿÿ  06/27/2013  00:16:30 qaser           hijitso            993.08 hffvcgcf          ÿÿ  06/27/2013  00:18:46 yuikl           hijitso            993.08 hffvcgcf          ÿÿ  06/27/2013  00:25:01 gcxsd           hijitso            999.18 hffvcgcf          ÿÿ  06/27/2013  00:40:45 hgdrt           sdfcdsfb              0.00 Normal          ÿÿ  06/27/2013  06:25:55 khuhukjmnj,l      sdfcdsfa             13.13 hasfldkdgh       ÿÿ  06/27/2013  06:25:55 khuhukjmnj,l      sdfcdsfc             13.13 hasfldkdgh       ÿÿ  06/27/2013  06:25:55 khuhukjmnj,l      sdfcdsfb             13.13 hasfldkdgh       ÿÿ  06/27/2013  06:27:16 khuhukjmnj,l      sdfcdsfa              0.00 Normal          ÿÿ  06/27/2013  06:27:16 khuhukjmnj,l      sdfcdsfc              0.00 Normal         fhfx  06/27/2013  06:27:16 khuhukjmnj,l      sdfcdsfb              0.00 Normal          ÿÿ  06/27/2013  06:28:05 khuhukjmnj,l      sdfcdsfa             10.79 hasfldkdgh       ÿÿ  06/27/2013  06:28:05 khuhukjmnj,l      sdfcdsfc             10.79 hasfldkdgh       ÿÿ 06/27/2013  06:30:05 khuhukjmnj,l      sdfcdsfc              9.38 hasfldkdgh       ÿÿ  06/27/2013  06:30:05 khuhukjmnj,l      sdfcdsfb              9.38 hasfldkdgh        ÿÿ                                                                                  ÿÿ                                                                                  ÿÿ                                                                                  ÿÿ                                                                                  ÿÿ                                                                                  ÿÿ               
I want to convert it to this format:
06/27/2013  06:27:16 khuhukjmnj,l      sdfcdsfc              0.00 Normal
I must say, my file is NOT a regular text format and it have some unreadable character when opening that in gedit, but emacs23 can open those files.
With GNU awk you can do something like this:
$ awk 'NR>1{print RS, $1, $2, $3, $4, $5, $6}' RS='fhfx' OFS='\t' file
fhfx    06/27/2013  00:05:55    RS_A1_6 hijitso 183.49  OverLow
fhfx    06/27/2013  00:16:30    qaser   hijitso 993.08  hffvcgcf
fhfx    06/27/2013  00:18:46    yuikl   hijitso 993.08  hffvcgcf
fhfx    06/27/2013  00:25:01    gcxsd   hijitso 999.18  hffvcgcf
fhfx    06/27/2013  00:40:45    hgdrt   sdfcdsfb    0.00    Normal
fhfx    06/27/2013  06:25:55    khuhukjmnj,l    sdfcdsfa    13.13   hasfldkdgh
fhfx    06/27/2013  06:25:55    khuhukjmnj,l    sdfcdsfc    13.13   hasfldkdgh
fhfx    06/27/2013  06:25:55    khuhukjmnj,l    sdfcdsfb    13.13   hasfldkdgh
fhfx    06/27/2013  06:27:16    khuhukjmnj,l    sdfcdsfa    0.00    Normal
fhfx    06/27/2013  06:27:16    khuhukjmnj,l    sdfcdsfc    0.00    Normal
fhfx    06/27/2013  06:27:16    khuhukjmnj,l    sdfcdsfb    0.00    Normal
fhfx    06/27/2013  06:28:05    khuhukjmnj,l    sdfcdsfa    10.79   hasfldkdgh
fhfx    06/27/2013  06:28:05    khuhukjmnj,l    sdfcdsfc    10.79   hasfldkdgh
fhfx    06/27/2013  06:30:05    khuhukjmnj,l    sdfcdsfc    9.38    hasfldkdgh
fhfx    06/27/2013  06:30:05    khuhukjmnj,l    sdfcdsfb    9.38    hasfldkdgh
Or if you want it prettier you can use column
$ awk 'NR>1{print RS, $1, $2, $3, $4, $5, $6}' RS='fhfx' file | column -t 
fhfx  06/27/2013  00:05:55  RS_A1_6       hijitso   183.49  OverLow
fhfx  06/27/2013  00:16:30  qaser         hijitso   993.08  hffvcgcf
fhfx  06/27/2013  00:18:46  yuikl         hijitso   993.08  hffvcgcf
fhfx  06/27/2013  00:25:01  gcxsd         hijitso   999.18  hffvcgcf
fhfx  06/27/2013  00:40:45  hgdrt         sdfcdsfb  0.00    Normal
fhfx  06/27/2013  06:25:55  khuhukjmnj,l  sdfcdsfa  13.13   hasfldkdgh
fhfx  06/27/2013  06:25:55  khuhukjmnj,l  sdfcdsfc  13.13   hasfldkdgh
fhfx  06/27/2013  06:25:55  khuhukjmnj,l  sdfcdsfb  13.13   hasfldkdgh
fhfx  06/27/2013  06:27:16  khuhukjmnj,l  sdfcdsfa  0.00    Normal
fhfx  06/27/2013  06:27:16  khuhukjmnj,l  sdfcdsfc  0.00    Normal
fhfx  06/27/2013  06:27:16  khuhukjmnj,l  sdfcdsfb  0.00    Normal
fhfx  06/27/2013  06:28:05  khuhukjmnj,l  sdfcdsfa  10.79   hasfldkdgh
fhfx  06/27/2013  06:28:05  khuhukjmnj,l  sdfcdsfc  10.79   hasfldkdgh
fhfx  06/27/2013  06:30:05  khuhukjmnj,l  sdfcdsfc  9.38    hasfldkdgh
fhfx  06/27/2013  06:30:05  khuhukjmnj,l  sdfcdsfb  9.38    hasfldkdgh
                        You can try this :
cat output.txt | sed 's/fhfx/\n&/g' | sed 's/ÿÿ *//g' | sed  '/fhfx/!d'
The result is :
fhfx 06/27/2013 00:05:55 RS_A1_6 hijitso 183.49 OverLow fhfx 06/27/2013 00:16:30 qaser hijitso 993.08 hffvcgcf fhfx 06/27/2013 00:18:46 yuikl hijitso 993.08 hffvcgcf fhfx 06/27/2013 00:25:01 gcxsd hijitso 999.18 hffvcgcf fhfx 06/27/2013 00:40:45 hgdrt sdfcdsfb 0.00 Normal fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfa 13.13 hasfldkdgh fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfc 13.13 hasfldkdgh fhfx 06/27/2013 06:25:55 khuhukjmnj,l sdfcdsfb 13.13 hasfldkdgh fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfa 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfc 0.00 Normal fhfx 06/27/2013 06:27:16 khuhukjmnj,l sdfcdsfb 0.00 Normal fhfx 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfa 10.79 hasfldkdgh fhfx 06/27/2013 06:28:05 khuhukjmnj,l sdfcdsfc 10.79 hasfldkdgh fhfx 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfc 9.38 hasfldkdgh fhfx 06/27/2013 06:30:05 khuhukjmnj,l sdfcdsfb 9.38 hasfldkdgh
You have a problem at the pre-last line, but I don't know if it's OK. I don't know wether you want to align your columns etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With