awk—pattern scanning and processing language
awk [ –fprogram–file ] [ –Fc ] [ prog ] [ parameters ] [ filename...]
awk scans each input filename for lines that match any of a set of patterns specified in prog.
Example A.4.
1 awk '{print $1, $2}' file
2 awk '/John/{print $3, $4}' file
3 awk -F: '{print $3}' /etc/passwd
4 date | awk '{print $6}'
EXPLANATION
Prints the first two fields of file where fields are separated by whitespace. Prints fields 3 and 4 if the pattern John is found. Using a colon as the field separator, prints the third field of the /etc/passwd file. Sends the output of the date command to awk and prints the sixth field.
|