Score:-1

Copy/Move Entire Line To End Of The Line Above

mx flag

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
Romeo Ninov avatar
in flag
Do you have more than one pair of such lines in the file?
djc72uk avatar
mx flag
Yes, multiple lines that all read and start with the long path followed by the next line with the numeric values.
Score:0
in flag

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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.