-
awk problem
I have the following awk script that sets a flag to 1 if Left is matched on a line, until that time left == 0. Then whenever the first field ($1) is between 1 and 100 I want to print $1 and if it is left or not. But whatever I try the value of $left is always the same as $1.
Does anybody know what I'm doing wrong?
Code:
$3 ~ /Left/ { left=1 }
$1 >= 1 && $1 <= 100 \
{
printf " ""%d"" ""%d"">\n", $1, $left
}
-
$left prints $1
You're thinking of Perl, which has $ in all scalar variable references
In awk, it's
printf " ""%d"" ""%d"">\n", $1, left
-
ah yes that works, thanks :)
I wasnt thinking of perl though since I never used it :)