Skip to main content
1 of 3
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
Costas
  • 15k
  • 24
  • 38