Commands.app

awk

Text Processing

Pattern scanning and text processing language

Examples
Common usage examples

Print first column of each line

awk '{print $1}' file.txt

Print lines matching pattern

awk '/pattern/ {print $0}' file.txt

Print username and command from ps output

ps aux | awk '{print $1, $11}'
Notes
  • Powerful for column-based data processing
  • $1, $2, etc. refer to columns (fields)
  • $0 refers to the entire line
Related Commands
You might also find these useful