AWK issue using unix scripts

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have this file



AK3*BPS*2
AK4*8*0510*1
AK3*RMT*12
AK4*1*0128*7*CR


and I want this output



BPS 2 1
RMT 12 7 CR


I am using this command



awk -F* '$1=="AK3" print $2, $3 "c" ($1=="AK4" print $4, $5 ' $FileHome/badfile_$session_num.txt >> $FileHome/input_output_record.txt


but i am getting this result



BPS 2
1
RMT 12
7 CR


Any hint will be appreciated







share|improve this question


















  • 1




    What's that c about? You seem to be missing a ) somewhere...
    – Kusalananda
    Dec 14 '17 at 15:03










  • What happens if you have a line starting with AK3 following another one with AK3?
    – ilkkachu
    Dec 14 '17 at 15:04














up vote
0
down vote

favorite












I have this file



AK3*BPS*2
AK4*8*0510*1
AK3*RMT*12
AK4*1*0128*7*CR


and I want this output



BPS 2 1
RMT 12 7 CR


I am using this command



awk -F* '$1=="AK3" print $2, $3 "c" ($1=="AK4" print $4, $5 ' $FileHome/badfile_$session_num.txt >> $FileHome/input_output_record.txt


but i am getting this result



BPS 2
1
RMT 12
7 CR


Any hint will be appreciated







share|improve this question


















  • 1




    What's that c about? You seem to be missing a ) somewhere...
    – Kusalananda
    Dec 14 '17 at 15:03










  • What happens if you have a line starting with AK3 following another one with AK3?
    – ilkkachu
    Dec 14 '17 at 15:04












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have this file



AK3*BPS*2
AK4*8*0510*1
AK3*RMT*12
AK4*1*0128*7*CR


and I want this output



BPS 2 1
RMT 12 7 CR


I am using this command



awk -F* '$1=="AK3" print $2, $3 "c" ($1=="AK4" print $4, $5 ' $FileHome/badfile_$session_num.txt >> $FileHome/input_output_record.txt


but i am getting this result



BPS 2
1
RMT 12
7 CR


Any hint will be appreciated







share|improve this question














I have this file



AK3*BPS*2
AK4*8*0510*1
AK3*RMT*12
AK4*1*0128*7*CR


and I want this output



BPS 2 1
RMT 12 7 CR


I am using this command



awk -F* '$1=="AK3" print $2, $3 "c" ($1=="AK4" print $4, $5 ' $FileHome/badfile_$session_num.txt >> $FileHome/input_output_record.txt


but i am getting this result



BPS 2
1
RMT 12
7 CR


Any hint will be appreciated









share|improve this question













share|improve this question




share|improve this question








edited Dec 14 '17 at 14:58









Jesse_b

10.5k22659




10.5k22659










asked Dec 14 '17 at 14:55









Antonio Pizarro

61




61







  • 1




    What's that c about? You seem to be missing a ) somewhere...
    – Kusalananda
    Dec 14 '17 at 15:03










  • What happens if you have a line starting with AK3 following another one with AK3?
    – ilkkachu
    Dec 14 '17 at 15:04












  • 1




    What's that c about? You seem to be missing a ) somewhere...
    – Kusalananda
    Dec 14 '17 at 15:03










  • What happens if you have a line starting with AK3 following another one with AK3?
    – ilkkachu
    Dec 14 '17 at 15:04







1




1




What's that c about? You seem to be missing a ) somewhere...
– Kusalananda
Dec 14 '17 at 15:03




What's that c about? You seem to be missing a ) somewhere...
– Kusalananda
Dec 14 '17 at 15:03












What happens if you have a line starting with AK3 following another one with AK3?
– ilkkachu
Dec 14 '17 at 15:04




What happens if you have a line starting with AK3 following another one with AK3?
– ilkkachu
Dec 14 '17 at 15:04










5 Answers
5






active

oldest

votes

















up vote
0
down vote













You seem to want:



  1. The last two fields of each AK3 line, followed by

  2. Fields four and five from the AK4 line (field five may be missing).

$ awk -F '*' '/^AK3/ printf("%st%s", $2, $3) /^AK4/ printf("t%st%sn", $4, $5) ' data.in
BPS 2 1
RMT 12 7 CR





share|improve this answer



























    up vote
    0
    down vote













    Another way is to directly control the output record separator(ORS)



    $ awk -F'*' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
    BPS 2 1
    RMT 12 7 CR


    • by default, output field separator(OFS) is single space

    • and input record separator(RS) is newline

    This is easy to modify for different OFS and also shows empty field



    $ awk -F'*' -v OFS=',' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
    BPS,2,1,
    RMT,12,7,CR





    share|improve this answer



























      up vote
      0
      down vote













      Plain print adds a newline (the output record separator), but printf doesn't, so we can use that on the AK3 case with an explicit separator between the fields. In the AK4 case, we want a field separator before the first field, and the simplest way to get that is to print an empty field first.



      $ awk -F* '$1=="AK3" printf "%s", $2 OFS $3 $1=="AK4" print "", $4, $5 ' < input 
      BPS 2 1
      RMT 12 7 CR


      This is easily converted to giving tab-spaced output, just add -vOFS='t' in the beginning of the command line.



      Though if you want fixed-width columns, it's probably easiest to use printf and width settings on the %s format:



      $ awk -F* '$1=="AK3" printf "%-3s %-2s", $2, $3 $1=="AK4" printf " %-1s %sn", $4, $5 ' < input
      BPS 2 1
      RMT 12 7 CR


      Over-long fields will still extend, unless you give the maximum field width too, with e.g. %-3.3s, and this will produce broken output if the input lines are not in correct order.






      share|improve this answer





























        up vote
        0
        down vote













        How about:



        awk -F '*' '
        printf "%s %s", $2, $3
        getline
        for (i=4; i<=NF; i++) printf " %s", $i
        print ""
        ' file | column -t




        BPS 2 1
        RMT 12 7 CR


        With plain bash:



        while IFS='*' read -r a1 b1 c1; IFS='*' read -r a2 b2 c3 rest
        do
        echo "$b1 $c1 $rest//*/ "
        done < file





        share|improve this answer




















        • I'm assuming there are always pairs of lines.
          – glenn jackman
          Dec 14 '17 at 15:59










        • Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
          – Antonio Pizarro
          Dec 14 '17 at 19:46











        • lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
          – glenn jackman
          Dec 14 '17 at 20:24

















        up vote
        0
        down vote













        I achieved the result by below commands




        sed -n '1~2p' testfile.txt| awk -F "*" 'print $2,$3' >> op.txt
        sed -n '2~2p' testfile.txt | awk -F "*" 'print $4,$5' >> op.txt

        sed -n '1~2p' op.txt |sed "N;s/n/ /g" |awk 'print $0"n"'; sed -n '2~2p' op.txt| sed "N;s/n/ /g"



        Output




        BPS 2 1



        RMT 12 7 CR









        share|improve this answer




















          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f410888%2fawk-issue-using-unix-scripts%23new-answer', 'question_page');

          );

          Post as a guest






























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          You seem to want:



          1. The last two fields of each AK3 line, followed by

          2. Fields four and five from the AK4 line (field five may be missing).

          $ awk -F '*' '/^AK3/ printf("%st%s", $2, $3) /^AK4/ printf("t%st%sn", $4, $5) ' data.in
          BPS 2 1
          RMT 12 7 CR





          share|improve this answer
























            up vote
            0
            down vote













            You seem to want:



            1. The last two fields of each AK3 line, followed by

            2. Fields four and five from the AK4 line (field five may be missing).

            $ awk -F '*' '/^AK3/ printf("%st%s", $2, $3) /^AK4/ printf("t%st%sn", $4, $5) ' data.in
            BPS 2 1
            RMT 12 7 CR





            share|improve this answer






















              up vote
              0
              down vote










              up vote
              0
              down vote









              You seem to want:



              1. The last two fields of each AK3 line, followed by

              2. Fields four and five from the AK4 line (field five may be missing).

              $ awk -F '*' '/^AK3/ printf("%st%s", $2, $3) /^AK4/ printf("t%st%sn", $4, $5) ' data.in
              BPS 2 1
              RMT 12 7 CR





              share|improve this answer












              You seem to want:



              1. The last two fields of each AK3 line, followed by

              2. Fields four and five from the AK4 line (field five may be missing).

              $ awk -F '*' '/^AK3/ printf("%st%s", $2, $3) /^AK4/ printf("t%st%sn", $4, $5) ' data.in
              BPS 2 1
              RMT 12 7 CR






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Dec 14 '17 at 15:13









              Kusalananda

              104k14206324




              104k14206324






















                  up vote
                  0
                  down vote













                  Another way is to directly control the output record separator(ORS)



                  $ awk -F'*' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                  BPS 2 1
                  RMT 12 7 CR


                  • by default, output field separator(OFS) is single space

                  • and input record separator(RS) is newline

                  This is easy to modify for different OFS and also shows empty field



                  $ awk -F'*' -v OFS=',' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                  BPS,2,1,
                  RMT,12,7,CR





                  share|improve this answer
























                    up vote
                    0
                    down vote













                    Another way is to directly control the output record separator(ORS)



                    $ awk -F'*' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                    BPS 2 1
                    RMT 12 7 CR


                    • by default, output field separator(OFS) is single space

                    • and input record separator(RS) is newline

                    This is easy to modify for different OFS and also shows empty field



                    $ awk -F'*' -v OFS=',' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                    BPS,2,1,
                    RMT,12,7,CR





                    share|improve this answer






















                      up vote
                      0
                      down vote










                      up vote
                      0
                      down vote









                      Another way is to directly control the output record separator(ORS)



                      $ awk -F'*' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                      BPS 2 1
                      RMT 12 7 CR


                      • by default, output field separator(OFS) is single space

                      • and input record separator(RS) is newline

                      This is easy to modify for different OFS and also shows empty field



                      $ awk -F'*' -v OFS=',' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                      BPS,2,1,
                      RMT,12,7,CR





                      share|improve this answer












                      Another way is to directly control the output record separator(ORS)



                      $ awk -F'*' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                      BPS 2 1
                      RMT 12 7 CR


                      • by default, output field separator(OFS) is single space

                      • and input record separator(RS) is newline

                      This is easy to modify for different OFS and also shows empty field



                      $ awk -F'*' -v OFS=',' '$1=="AK3"ORS=OFS; print $2, $3 $1=="AK4"ORS=RS; print $4, $5' ip.txt
                      BPS,2,1,
                      RMT,12,7,CR






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Dec 14 '17 at 15:21









                      Sundeep

                      6,9511826




                      6,9511826




















                          up vote
                          0
                          down vote













                          Plain print adds a newline (the output record separator), but printf doesn't, so we can use that on the AK3 case with an explicit separator between the fields. In the AK4 case, we want a field separator before the first field, and the simplest way to get that is to print an empty field first.



                          $ awk -F* '$1=="AK3" printf "%s", $2 OFS $3 $1=="AK4" print "", $4, $5 ' < input 
                          BPS 2 1
                          RMT 12 7 CR


                          This is easily converted to giving tab-spaced output, just add -vOFS='t' in the beginning of the command line.



                          Though if you want fixed-width columns, it's probably easiest to use printf and width settings on the %s format:



                          $ awk -F* '$1=="AK3" printf "%-3s %-2s", $2, $3 $1=="AK4" printf " %-1s %sn", $4, $5 ' < input
                          BPS 2 1
                          RMT 12 7 CR


                          Over-long fields will still extend, unless you give the maximum field width too, with e.g. %-3.3s, and this will produce broken output if the input lines are not in correct order.






                          share|improve this answer


























                            up vote
                            0
                            down vote













                            Plain print adds a newline (the output record separator), but printf doesn't, so we can use that on the AK3 case with an explicit separator between the fields. In the AK4 case, we want a field separator before the first field, and the simplest way to get that is to print an empty field first.



                            $ awk -F* '$1=="AK3" printf "%s", $2 OFS $3 $1=="AK4" print "", $4, $5 ' < input 
                            BPS 2 1
                            RMT 12 7 CR


                            This is easily converted to giving tab-spaced output, just add -vOFS='t' in the beginning of the command line.



                            Though if you want fixed-width columns, it's probably easiest to use printf and width settings on the %s format:



                            $ awk -F* '$1=="AK3" printf "%-3s %-2s", $2, $3 $1=="AK4" printf " %-1s %sn", $4, $5 ' < input
                            BPS 2 1
                            RMT 12 7 CR


                            Over-long fields will still extend, unless you give the maximum field width too, with e.g. %-3.3s, and this will produce broken output if the input lines are not in correct order.






                            share|improve this answer
























                              up vote
                              0
                              down vote










                              up vote
                              0
                              down vote









                              Plain print adds a newline (the output record separator), but printf doesn't, so we can use that on the AK3 case with an explicit separator between the fields. In the AK4 case, we want a field separator before the first field, and the simplest way to get that is to print an empty field first.



                              $ awk -F* '$1=="AK3" printf "%s", $2 OFS $3 $1=="AK4" print "", $4, $5 ' < input 
                              BPS 2 1
                              RMT 12 7 CR


                              This is easily converted to giving tab-spaced output, just add -vOFS='t' in the beginning of the command line.



                              Though if you want fixed-width columns, it's probably easiest to use printf and width settings on the %s format:



                              $ awk -F* '$1=="AK3" printf "%-3s %-2s", $2, $3 $1=="AK4" printf " %-1s %sn", $4, $5 ' < input
                              BPS 2 1
                              RMT 12 7 CR


                              Over-long fields will still extend, unless you give the maximum field width too, with e.g. %-3.3s, and this will produce broken output if the input lines are not in correct order.






                              share|improve this answer














                              Plain print adds a newline (the output record separator), but printf doesn't, so we can use that on the AK3 case with an explicit separator between the fields. In the AK4 case, we want a field separator before the first field, and the simplest way to get that is to print an empty field first.



                              $ awk -F* '$1=="AK3" printf "%s", $2 OFS $3 $1=="AK4" print "", $4, $5 ' < input 
                              BPS 2 1
                              RMT 12 7 CR


                              This is easily converted to giving tab-spaced output, just add -vOFS='t' in the beginning of the command line.



                              Though if you want fixed-width columns, it's probably easiest to use printf and width settings on the %s format:



                              $ awk -F* '$1=="AK3" printf "%-3s %-2s", $2, $3 $1=="AK4" printf " %-1s %sn", $4, $5 ' < input
                              BPS 2 1
                              RMT 12 7 CR


                              Over-long fields will still extend, unless you give the maximum field width too, with e.g. %-3.3s, and this will produce broken output if the input lines are not in correct order.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Dec 14 '17 at 15:23

























                              answered Dec 14 '17 at 15:11









                              ilkkachu

                              49.9k674137




                              49.9k674137




















                                  up vote
                                  0
                                  down vote













                                  How about:



                                  awk -F '*' '
                                  printf "%s %s", $2, $3
                                  getline
                                  for (i=4; i<=NF; i++) printf " %s", $i
                                  print ""
                                  ' file | column -t




                                  BPS 2 1
                                  RMT 12 7 CR


                                  With plain bash:



                                  while IFS='*' read -r a1 b1 c1; IFS='*' read -r a2 b2 c3 rest
                                  do
                                  echo "$b1 $c1 $rest//*/ "
                                  done < file





                                  share|improve this answer




















                                  • I'm assuming there are always pairs of lines.
                                    – glenn jackman
                                    Dec 14 '17 at 15:59










                                  • Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
                                    – Antonio Pizarro
                                    Dec 14 '17 at 19:46











                                  • lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
                                    – glenn jackman
                                    Dec 14 '17 at 20:24














                                  up vote
                                  0
                                  down vote













                                  How about:



                                  awk -F '*' '
                                  printf "%s %s", $2, $3
                                  getline
                                  for (i=4; i<=NF; i++) printf " %s", $i
                                  print ""
                                  ' file | column -t




                                  BPS 2 1
                                  RMT 12 7 CR


                                  With plain bash:



                                  while IFS='*' read -r a1 b1 c1; IFS='*' read -r a2 b2 c3 rest
                                  do
                                  echo "$b1 $c1 $rest//*/ "
                                  done < file





                                  share|improve this answer




















                                  • I'm assuming there are always pairs of lines.
                                    – glenn jackman
                                    Dec 14 '17 at 15:59










                                  • Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
                                    – Antonio Pizarro
                                    Dec 14 '17 at 19:46











                                  • lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
                                    – glenn jackman
                                    Dec 14 '17 at 20:24












                                  up vote
                                  0
                                  down vote










                                  up vote
                                  0
                                  down vote









                                  How about:



                                  awk -F '*' '
                                  printf "%s %s", $2, $3
                                  getline
                                  for (i=4; i<=NF; i++) printf " %s", $i
                                  print ""
                                  ' file | column -t




                                  BPS 2 1
                                  RMT 12 7 CR


                                  With plain bash:



                                  while IFS='*' read -r a1 b1 c1; IFS='*' read -r a2 b2 c3 rest
                                  do
                                  echo "$b1 $c1 $rest//*/ "
                                  done < file





                                  share|improve this answer












                                  How about:



                                  awk -F '*' '
                                  printf "%s %s", $2, $3
                                  getline
                                  for (i=4; i<=NF; i++) printf " %s", $i
                                  print ""
                                  ' file | column -t




                                  BPS 2 1
                                  RMT 12 7 CR


                                  With plain bash:



                                  while IFS='*' read -r a1 b1 c1; IFS='*' read -r a2 b2 c3 rest
                                  do
                                  echo "$b1 $c1 $rest//*/ "
                                  done < file






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Dec 14 '17 at 15:54









                                  glenn jackman

                                  46.7k265103




                                  46.7k265103











                                  • I'm assuming there are always pairs of lines.
                                    – glenn jackman
                                    Dec 14 '17 at 15:59










                                  • Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
                                    – Antonio Pizarro
                                    Dec 14 '17 at 19:46











                                  • lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
                                    – glenn jackman
                                    Dec 14 '17 at 20:24
















                                  • I'm assuming there are always pairs of lines.
                                    – glenn jackman
                                    Dec 14 '17 at 15:59










                                  • Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
                                    – Antonio Pizarro
                                    Dec 14 '17 at 19:46











                                  • lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
                                    – glenn jackman
                                    Dec 14 '17 at 20:24















                                  I'm assuming there are always pairs of lines.
                                  – glenn jackman
                                  Dec 14 '17 at 15:59




                                  I'm assuming there are always pairs of lines.
                                  – glenn jackman
                                  Dec 14 '17 at 15:59












                                  Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
                                  – Antonio Pizarro
                                  Dec 14 '17 at 19:46





                                  Wow! Thank you very much for all the answers I tried all of them and I always got the result that I was expecting. Amazing ! help
                                  – Antonio Pizarro
                                  Dec 14 '17 at 19:46













                                  lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
                                  – glenn jackman
                                  Dec 14 '17 at 20:24




                                  lol. Give a fun puzzle to a bunch of nerds, you'll get a lot of responses.
                                  – glenn jackman
                                  Dec 14 '17 at 20:24










                                  up vote
                                  0
                                  down vote













                                  I achieved the result by below commands




                                  sed -n '1~2p' testfile.txt| awk -F "*" 'print $2,$3' >> op.txt
                                  sed -n '2~2p' testfile.txt | awk -F "*" 'print $4,$5' >> op.txt

                                  sed -n '1~2p' op.txt |sed "N;s/n/ /g" |awk 'print $0"n"'; sed -n '2~2p' op.txt| sed "N;s/n/ /g"



                                  Output




                                  BPS 2 1



                                  RMT 12 7 CR









                                  share|improve this answer
























                                    up vote
                                    0
                                    down vote













                                    I achieved the result by below commands




                                    sed -n '1~2p' testfile.txt| awk -F "*" 'print $2,$3' >> op.txt
                                    sed -n '2~2p' testfile.txt | awk -F "*" 'print $4,$5' >> op.txt

                                    sed -n '1~2p' op.txt |sed "N;s/n/ /g" |awk 'print $0"n"'; sed -n '2~2p' op.txt| sed "N;s/n/ /g"



                                    Output




                                    BPS 2 1



                                    RMT 12 7 CR









                                    share|improve this answer






















                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      I achieved the result by below commands




                                      sed -n '1~2p' testfile.txt| awk -F "*" 'print $2,$3' >> op.txt
                                      sed -n '2~2p' testfile.txt | awk -F "*" 'print $4,$5' >> op.txt

                                      sed -n '1~2p' op.txt |sed "N;s/n/ /g" |awk 'print $0"n"'; sed -n '2~2p' op.txt| sed "N;s/n/ /g"



                                      Output




                                      BPS 2 1



                                      RMT 12 7 CR









                                      share|improve this answer












                                      I achieved the result by below commands




                                      sed -n '1~2p' testfile.txt| awk -F "*" 'print $2,$3' >> op.txt
                                      sed -n '2~2p' testfile.txt | awk -F "*" 'print $4,$5' >> op.txt

                                      sed -n '1~2p' op.txt |sed "N;s/n/ /g" |awk 'print $0"n"'; sed -n '2~2p' op.txt| sed "N;s/n/ /g"



                                      Output




                                      BPS 2 1



                                      RMT 12 7 CR










                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Dec 14 '17 at 19:02









                                      Praveen Kumar BS

                                      1,010128




                                      1,010128






















                                           

                                          draft saved


                                          draft discarded


























                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f410888%2fawk-issue-using-unix-scripts%23new-answer', 'question_page');

                                          );

                                          Post as a guest













































































                                          Popular posts from this blog

                                          How to check contact read email or not when send email to Individual?

                                          Displaying single band from multi-band raster using QGIS

                                          How many registers does an x86_64 CPU actually have?