Raw Input Desired Output
Line 1.
Line 2.
Line 3.
Line 4.
Line 5.
Line 6.
Line 7.
Line 1.
Line 2.Line 1.
Line 3.Line 2.
Line 4.Line 3.
Line 5.Line 4.
Line 6.Line 5.
Line 7.Line 6.
Script and Comments
Script1
[ 1] H
[ 2] x
[ 3] s/^\(.*\)\n\(.*\)/\2\1/
Comments
  1. Pattern Space and Hold Space are abbreviated to PS and HS, respectively.
  2. We use HS to keep the previous line of a line.
  3. For example, if a cycle read the line Line 3. of the datafile, before Step [1], HS contains Line 2., the previous line:
    After StepCommandPSHS
    initially Line 3.Line 2.
    [1]HLine 3.Line 2.\n Line 3.
    [2]xLine 2.\n Line 3.Line 3.
    [3]s/^\(.*\)\n\(.*\)/\2\/1/Line 3.Line 2.Line 3.