I have a file that is like
1 test test
How can I remove the new line from the so the final output becomes:
1 test test
A solution using 'sed':
Input file (infile):
1 test
test
2 two
3 three
4 four
five
six
7 seven
eight
9 nine
'Sed' program (script.sed):
/[0-9]\+/ {
: a
N
/\n[0-9]\+/ {
P
s/.*\n//
}
t a
}
y/\n/ /
Execution:
$ sed -f script.sed infile
Output:
1 test test
2 two
3 three
4 four five
six
7 seven eight
9 nine