unexpected output within a for loop using awk

Hi all,
after hours of playing around with this and scouring the web I decided to ask my fellow UNIX operators as I can't wrap my head around this.

First off,
I want to parse an input file with tabs (I could pull this off easily with different delimiters) but I was trying to make nicer looking input files.
Here's my input file

# cat databases.lst
#NOTE: These entries are delimited by tabs "\t"
#oracleSID      name/pass
#
db11    harry/hill
db22    bill/peter
test    erin/ast
 

Now running this awk statement alone works as intended (I can manipulate fields 1 and 2

# cat databases.lst | awk 'BEGIN{min=3; RS="\n"; FS="\t"} { if (NR>min) print $1,$2 }'
db11 harry/hill
db22 bill/peter
test erin/ast
 

But here's my problem; I need to parse through each recordset to create paramter files for oracle (I manipulate fields 1 and 2). And to iterate through the file I put the code in a for loop which I was hoping to manipulate each row (with fields 1 and 2) but with each iteration I am getting each FIELD.

#!/usr/bin/ksh
count=0
for row in `cat databases.lst | awk 'BEGIN{min=3; RS="\n"; FS="\t"} { if (NR>min) print }'`
        do
                count=$(($count+1))
                echo $row
                echo $count
        done
# ./file22
db11
1
harry/hill
2
db22
3
bill/peter
4
test
5
erin/ast
6
 

Now I can use my awk statement by itself; but how do put this command in my for loop without taking each field as an interation?

If I were to change my tab delimiter to : it works fine as the entire line is taken in. Any ideas? If I have to I will use the colon; but it would've been cool to know how to manipulate tabbed entries in a file.

Thanks for everything
Erin

That's a useless use of cat.

That's a useless use of backticks, too.

How about

COUNT=0
awk 'BEGIN{min=3; RS="\n"; FS="\t"} { if (NR>min) print }' databases.lst | while read A B
do
       echo $((++COUNT))
       echo $A
done

But really, for something this simple you could just do it all in awk.

Hi Corona688,

I want to thank you SO much for opening my eyes to my bad coding practices. I've made the changes and it looks good; I'm going to go back and clean up some of my previous scripts too :slight_smile: