The following awk statement will print any user id that has a group id of 3.
In other words if the number in column 4 is a 3 , print column 1.
# awk -F: '{if ($4 =="3") print $1}' /etc/passwd root sys uucp
$0 will print the entire line if the group id is 3.
# awk -F: '{if ($4 =="3") print $0}' /etc/passwd
If my file is a | for a field separator it will check for number 9 to match THIS and field number 11 to match that.
If it finds a patch it will print the fields 2 9 and 11.
awk "-F|" '{if ($9 == "THIS" && $11 == "THAT") print $2,$9,$11;}' /home/user/myfile
Need to add a variable
If my file is a | for a field separator it will check for the 2nd field to the variable host
If it finds a patch it will print the fields 20 in lower case letters.
# myhost=linuxprd1 # awk -v host=${myhost} "-F|" '{if ( $2 == host ) print tolower($20)}' /home/user/myfile