A:
  It is clear from this code fragment that 
awk
 is supposed to compare 
$2
 with 
"income"
. If you think about it (or change 
awk
 to 
echo
 above), you will see that you have given the following to 
awk
:
A:
{if($2==income) { /* THIS LINE IS THE PROBLEM */
A:
 What does 
awk
 do with this? It compares 
$2
 with the contents of the variable 
income
. If 
income
 has not been set, it compares it with zero or with the null string. Instead, you want:
A:
{ if ($2 == "income") {
A: which you can say with:
A:
case $col2 in income)         awk '         {                 if ($2 == "'$col2'") {                         ... awk code ...                 }         }' $file1;;
Replacing commands with 
echo
 in shell scripts is a handy debugging trick.
- in net.unix on Usenet, 1 November 1986