|
Introduction to AWK
The basic function of awk is to search files for lines or other text units containing one or more patterns. When a line matches one of the patterns, special actions are performed on that line.
Display user names from /etc/passwd (field 1):
Where F is the field separator; in passwd file, fields are separated by ':'
Default field separator is a blank space. Awk scans the input file and
splits each input line into fields.
Similarly:
Display user names home directories and login shell (fields 1 and 7):
and store them in a separate file, users.txt
or
Default field separator is empty space. To print users (field 1) from just
created file users.txt:
Recommended tutorial: The GNU awk programming language
|
|