grep with cut option??

This is my command-line code in my script,

passwd=`grep $passwd $userfile |  cut -f2 -d: login_users > retrieve`

the

cut -f2 -d: login_users > retrieve

searches and prints the whole column two. what I need is one of the items in the column two only.. what option can I add to my cut command??

here is an example, all files in column 2..

aaa
bbb
ccc

then, what I want to print is just the aaa.. what will I do??

Try this :

passwd=`grep $passwd $userfile | awk -F ":" '{print $2}' | awk NR==3`

This will select the 2nd field and the 3rd line.

login_user="aaa"
passwd=`awk -v p=$login_user -F: '$0~p {print $2}' $userfile`