In a text document I want to concatenate every other line with the next. I guess sed is the thing to use? How would this be done?
Unless you're really insistent that it need be sed, just pipe it through
paste -d" " - -
This might work for you:
seq 10 | sed '$!N;s/\n/ /'
1 2
3 4
5 6
7 8
9 10
If is not the last line, append the following line to current line and replace the newline by a space.
awk
solution:awk '{getline b;printf("%s %s\n",$0,b)}' file
[jaypal:~/Temp] seq 11 > file
[jaypal:~/Temp] awk '{getline b;printf("%s %s\n",$0,b)}' file
1 2
3 4
5 6
7 8
9 10
11
This is easiest using paste:
paste -s -d' \n' input.txt
Although there's a Famous Sed One-Liner (38) to emulate this as in potong's answer.
What do you mean by "in a text document"? If you are editing the file with vim, you can do:
:g/./normal J