AWK Patterns
The -F option with the colon(:) indicates our field separator is the colon.
The regular expression indicates to match ksh at the end of each password record.
- The action statement says print the username or login name.
- The action will take place if the pattern match is true.
awk -F: ‘ /ksh$/ { print $1 } ‘ /etc/passwd
compound pattern {statement(s)}
- Field Separator is the UNIX pipe character(|).
- Determine if field six equals the character string "CA"
- Determine if field five is like "San Jose"
awk -F”|” ‘ $6 == “CA” && $5 ~ /San Jose/ ‘ phone.lst