1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format:

1st line,2nd line
3rd line,4th line
5th line,6th line
...

Thanks!

awk '{ getline VAR ; printf ("%s,%s\n", $0, VAR); }' filename

That's only giving me:

,2nd line
,4th line
,6th line
...

I need:

1st line,2nd line
3rd line,4th line
5th line,6th line

Thanks for the quick response

Huh? I get the desired output with the solution of Corona688... Another one assuming the file has even numbers of lines:

awk 'NR%2{s=$0 ",";next}{print s $0}' file
sed -n 'h;n;H;x;s/\n/,/;p' infile
1 Like

-bash-3.00$ awk 'NR%2{s=$0 ",";next}{print s $0}' infile>outfile
awk: syntax error near line 1
awk: bailing out near line 1

no good

---------- Post updated at 08:05 AM ---------- Previous update was at 08:03 AM ----------

Code:
sed -n 'h;n;H;x;s/\n/,/;p' infile

Looks good! thanks

Use nawk or /usr/xpg4/bin/awk on Solaris.