How to convert rows to columns in unix
This is a minimal awk
solution:
awk 'ORS=NR%4?" ":"\n"' input.txt
output
jobname userid starttime endtimejobname2 userid starttime endtime
(If you want to align the fields, pipe to column -t
)
This will paste each four consecutive lines as four tab-delimited fields:
cat source_file | paste - - - - > destination_file
If you are looking for a shell script, you can do this as the number of lines to be printed in the output seems to have to fixed length:
while read line1; do read line2 read line3 read line4 echo $line1 $line2 $line3 $line4 >>outputdone <file