I'm trying to get a string from a line from a file from user input.
It should output a name like this: Tharahan Muthu
from a string of letters like this:
muthu:x:14232:504:Tharahan Muthu:/home/staff/muthu:/bin/bash
The name is always the 5th and 6th element.
It works fine, up to the awk line, after which it does not print anything.
#! /bin/bash
clear
echo "Type your n number"
read name
var1=$(grep -n $name /etc/passwd)
awk -v var="$var1" -F "[: ]" '/$0~var/{print $5" " $6 }' /etc/passwd
edit: fixed a typo where var="$var1" was typed var="$var2"