awk
Program: awk
Processes text line by line with a small program.
Usage
awk [-F FS] [-v VAR=VALUE] [-f PROGFILE | 'PROGRAM'] [VAR=VALUE | FILE]...
Description
Run the PROGRAM on every line of the FILEs (or of the keyboard or pipe). A program is a list of PATTERN { ACTION }: the ACTION runs for each line that matches the PATTERN. $1, $2, ... are the fields of the line, $0 is the whole line, NR counts lines, NF counts fields. BEGIN { ... } runs before the first line, END { ... } after the last.
Options in the simulator
1 more options of the real program, not in the simulator yet
Examples
awk '{print $1}' logs/app.log.1
23:40:12
23:45:31
23:52:08
23:59:58
awk '{print $2, $NF}' logs/app.log.1
INFO 77ms
INFO entries
WARN 1320ms
INFO rotated Where you learn it
Lessons
- Evaluating columns with awk Linux Basics, Module 3: Text tools