awk -F: 'substr($1,0,1)=="p" {print $3}' /etc/passwd perl -F: -lane 'substr($F[0],0,1)eq"p" and print $F[2]' /etc/passwd