Hi, guys. I am new to Linux, I spend quite a while on the problem below, but still couldn't figure it out, hope some of you can give me a hand.

The question is:

I have a variable called $username, and a file called users, which contains all the usernames. I want to write a script to count how many usernames begins with $username. For example:

$username is "whelanp"

in file "users"
**********
at:21
ftp:34
.....
leeb:5000
whelanp:5001
whelanp2:5002
whelanp3:5003
hynesj:5004
sherrys:5005
**********

I want to find out how many usernames begin with "whelanp", and I also want to find out what is the biggest number after "whelanp", in this example it will be 3.

The following is my script, but I couldn't go any further, hope somebody can help me.

-----------------------------------------------
user_list=$(cat $etcdir/users | awk 'BEGIN {FS = ":"} ; { if ($2 >= 5000) { print $1 } }' )
-----------------------------------------------


Thanks a lot in advance

-K.D.