Awk is awesome of text manipulation, but a little opaque to me. I would like to run an awk command that boils down to something like this
awk '{$x = ($3 > 0 ? 1 : -1); print $1*$x "\t" $2*$x}' file
I want to assign $x on each line, i.e. not using the -v option, and then use it inside my print statement. Unforunately, after the ; awk has forgotten the values of $1 and $2. And putting the assignment outside the braces doesn't seem to work either. How does this work?