How to awk/sed/grep lines which contains a pattern at a given position

Dear friends

I am new to linux and was trying to split some files userwise in our linux server.

I have a data file of 156 continuous columns named ecscr final.

I want the script to redirect all the lines containing a pattern of 7 digits to separate files. I was using grep to do that, as below. I have written all available patterns to a file named usercode.

while read alpha
do
cat ecscrfinal | grep -e $alpha >> mkoff.$alpha
echo "Generating markoff data for $alpha"
done < /home/ftp/ecs/usercode

But I need only those lines which have the pattern occuring at 3rd column or 81st column to go to that file. In the above case if the pattern is found any wher in the line, it is redirected to that file which gives me a wrong result.

How sed/awk/grep can be used to match a pattern occuring only at a specified field.....?

The pattern should be matched only if it is occuring in 3rd position or 81st postition.

Please help me.....i am running against a deadline.........

> cat file20
abcde1234567ffffffffggggggg
abcdezzzzzzzffffffffggggggg
abczzyyyyyyygggggggg1212121

> awk 'substr($0,6,7)<"AAAAAAA" || substr($0,21,7)<"AAAAAAA"' file20
abcde1234567ffffffffggggggg
abczzyyyyyyygggggggg1212121

It selects records that are numeric at either of two positions in the data record.

i tried like this

while read alpha
do
awk 'substr($0,3,7)<"$alpha"||substr($0,81,7)<"$alpha"'<ecscrfinal >> mkoff.$alpha
awk 'substr($0,3,7)<"$alpha"||substr($0,81,7)<"$alpha"' <ecsdrfinal >> mkoff.$alpha
done < /home/ftp/ecs/usercode

which yielded no results

then like this, $alph without quotes;

while read alpha
do
awk 'substr($0,3,7)<$alpha||substr($0,81,7)<$alpha'<ecscrfinal >> mkoff.$alpha
awk 'substr($0,3,7)<$alpha||substr($0,81,7)<$alpha' <ecsdrfinal >> mkoff.$alpha
done < /home/ftp/ecs/usercode

In this case the entire file is copied to all the userwise split files

What I am doing wrong..... Cant I do substitution inside awk...??