-1

I have a file that looks like the following:

/path/to/a/very/long/path
       0 0 0 0 0 0

I need to move the line starting with a number (this can be any value not necessarily 0) to the end of the preceding line so that it looks like the following:

/path/to/a/very/long/path 0 0 0 0 0
djc72uk
  • 33
  • 1
  • 6

1 Answers1

0

Some awk program can do the work line this:

awk '{if(NR%2==0) {print var,$0} else {var=$0}}' input_file >output_file

It use awk internal variable NR which is the number of current line.

Here is example:

# cat qs
/path/to/a/very/long/path
       0 0 0 0 0 0
/path/to/a/very/long/path
       1 2 0 0 0 0


# awk '{if(NR%2==0) {print var,$0} else {var=$0}}' qs
/path/to/a/very/long/path        0 0 0 0 0 0
/path/to/a/very/long/path        1 2 0 0 0 0
Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26