Sometimes it's all about the aesthetics.

8/14/2009

awk stuff

AWK can also be used to generate lazy code.

$ awk '/Block inner limits/{print $4,$5}' b37.out | awk '\
? NR==1        {printf "if      ( h*i+gox >=%6.1f .and. h*i+gox <=%6.1f .and. &\n",$1,$2} \
? NR>1&&NR%3==1{printf "else if ( h*i+gox >=%6.1f .and. h*i+gox <=%6.1f .and. &\n",$1,$2}\
? NR%3==2      {printf "          h*j+goy >=%6.1f .and. h*j+goy <=%6.1f .and. &\n",$1,$2}\
? NR%3==0      {printf "          h*k+goz >=%6.1f .and. h*k+goz <=%6.1f ) then\n"$1,$2}\
? NR%3==0      {printf "   write(%d,\47(4f)\47) mytmp,h*i+gox,h*j+goy,h*k+goz\n",8000+NR/3}'

No comments: