Skip to main content
added 223 characters in body
Source Link
Costas
  • 15k
  • 24
  • 38

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '
     /^\w/{
           s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*/ /
    ' > xyz.txt

Or if you like awk

awk '
     /[A-Z]/ {
             print $0, ++count
             getline
             printf "%s " %s", $0
             next
     }
     {
       }      print "", $0
     1}
    ' abc.txt > xyz.txt

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '/^\w/{s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*//
    ' > xyz.txt

Or if you like awk

awk '/[A-Z]/{
             print $0, ++count
             getline
             printf "%s ", $0
             next
            }
     1
    ' abc.txt > xyz.txt

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '
     /^\w/{
           s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*/ /
    ' > xyz.txt

Or if you like awk

awk '
     /[A-Z]/ {
             print $0, ++count
             getline
             printf " %s", $0
             next
     }
     {
             print "", $0
     }
    ' abc.txt > xyz.txt
added 223 characters in body
Source Link
Costas
  • 15k
  • 24
  • 38

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '/^\w/{s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*//
    ' > xyz.txt

Or if you like awk

awk '/[A-Z]/{
             print $0, ++count
             getline
             printf "%s ", $0
             next
            }
     1
    ' abc.txt > xyz.txt

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '/^\w/{s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*//
    ' > xyz.txt

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '/^\w/{s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*//
    ' > xyz.txt

Or if you like awk

awk '/[A-Z]/{
             print $0, ++count
             getline
             printf "%s ", $0
             next
            }
     1
    ' abc.txt > xyz.txt
Source Link
Costas
  • 15k
  • 24
  • 38

There are 2 tasks: numerate apropriate line(s) than format output:

nl -bp[A-Z] -nln abc.txt | 
sed '/^\w/{s/\(.*\)\(....\)/\2 \1/
           n
           N
           s/\n\s*/ /
          }
     s/^\s*//
    ' > xyz.txt