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
You can be a bit smarter and print a new line before the line if it starts with a digit (except for the first line);
awk 'BEGIN{ORS="";} NR==1 { print; next; } /^[[:digit:]]/ { print "\n"; print; next; } { print; }'
The awk script:
BEGIN { ORS=""; } # default: no newline between output records
NR==1 { print; next; } # first line: print
/^[[:digit:]]/ { print "\n"; print; next; } # if starts with a digit: print newline before
{print;} # other lines (next; has not been called yet)