Skip to main content

With the sed editorsed tool, you can do like shown:

  sed  -i  -e '
              /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
              N;s/\n/ /
              s/^/\n/;D
   '     . /*.csv

Method###Explanation:

 °  branch to end of sed code processing for the current pattern space data when an even number of pipes are found. 

°   or, go fetch the next line and append it to the pattern space. 

 °  now reapply the sed code all over again on the pattern space. 



     perl -i.BAK    -lpe '
         $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
      '     . /*.csv 

  °  $k is a running counter of number if pipes seen at any time.

  °  for even we print with a newline, otherwise we join the lines with a space. 
  1. Branch to end of sed code processing for the current pattern space data when an even number of pipes are found.

  2. Or, go fetch the next line and append it to the pattern space.

  3. Now reapply the sed code all over again on the pattern space.

      perl -i.BAK    -lpe '
          $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
       '     . /*.csv 
    
  4. $k is a running counter of number if pipes seen at any time.

  5. For even we print with a newline, otherwise we join the lines with a space.

With the sed editor you can do like shown

  sed  -i  -e '
              /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
              N;s/\n/ /
              s/^/\n/;D
   '     . /*.csv

Method:

 °  branch to end of sed code processing for the current pattern space data when an even number of pipes are found. 

°   or, go fetch the next line and append it to the pattern space. 

 °  now reapply the sed code all over again on the pattern space. 



     perl -i.BAK    -lpe '
         $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
      '     . /*.csv 

  °  $k is a running counter of number if pipes seen at any time.

  °  for even we print with a newline, otherwise we join the lines with a space. 

With the sed tool, you can do like shown:

sed  -i  -e '
             /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
             N;s/\n/ /
             s/^/\n/;D
   '     . /*.csv

###Explanation:

  1. Branch to end of sed code processing for the current pattern space data when an even number of pipes are found.

  2. Or, go fetch the next line and append it to the pattern space.

  3. Now reapply the sed code all over again on the pattern space.

      perl -i.BAK    -lpe '
          $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
       '     . /*.csv 
    
  4. $k is a running counter of number if pipes seen at any time.

  5. For even we print with a newline, otherwise we join the lines with a space.

added 439 characters in body
Source Link

With the sed editor you can do like shown

  sed  -i  -e '
              /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
              N;s/\n/ /
              s/^/\n/;D
   '     . /*. csv

Method:

 °  branch to end of sed code processing for the current pattern space data when an even number of pipes are found. 

°   or, go fetch the next line and append it to the pattern space. 

 °  now reapply the sed code all over again on the pattern space. 



     perl -i.BAK    -lpe '
         $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
      '     . /*.csv 

  °  $k is a running counter of number if pipes seen at any time.

  °  for even we print with a newline, otherwise we join the lines with a space. 

With the sed editor you can do like shown

  sed  -i  -e '
              /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
              N;s/\n/ /
              s/^/\n/;D
   '     . /*. csv

     perl -i.BAK    -lpe '
         $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
      '     . /*.csv  

With the sed editor you can do like shown

  sed  -i  -e '
              /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
              N;s/\n/ /
              s/^/\n/;D
   '     . /*.csv

Method:

 °  branch to end of sed code processing for the current pattern space data when an even number of pipes are found. 

°   or, go fetch the next line and append it to the pattern space. 

 °  now reapply the sed code all over again on the pattern space. 



     perl -i.BAK    -lpe '
         $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
      '     . /*.csv 

  °  $k is a running counter of number if pipes seen at any time.

  °  for even we print with a newline, otherwise we join the lines with a space. 
Source Link

With the sed editor you can do like shown

  sed  -i  -e '
              /^\(\([^|]*|\)\{2\}\)*[^|]*$/b
              N;s/\n/ /
              s/^/\n/;D
   '     . /*. csv

     perl -i.BAK    -lpe '
         $\ = ( $k += tr/|/|/ ) =~ /[24680]$/ ? "\n" : " ";
      '     . /*.csv