Here's a too-literal, non-scalable, ultra-short awk
version:
awk '{printf "%s\n%s\n%s\n\n%s\n%s\n%s\n",$1,$3,$5,$2,$4,$6}'
A little longer (two more characters) using nested loops (prints an extra line of a new line at the end):
awk '{for(i=1;i<=2;i++){for(j=i;j<=NF;j+=2)print $j;print ""}}'
Does not print an extra line of a new line:
awk '{for(i=1;i<=2;i++){for(j=i;j<=NF;j+=2)print $j;if(i==1)print ""}}'
For comparison: the paxdiablo version with all unnecessary characters is deleted (1, 9 or 11 more characters):
awk '{for(i=1;i<=NF;i+=2)print $i;print "";for(i=2;i<=NF;i+=2)print $i}'
Here is the all- bash version:
d=(abc edf xyz rfg yeg udh) i="0 2 4 1 3 5" for w in $i do echo ${d[$w]} [[ $w == 4 ]]&&echo done
Dennis Williamson Oct 23 '09 at 7:36 2009-10-23 07:36
source share