awk 'pattern {action}' file

Built-in Variables

1. Printing Specific Columns

Use awk to extract specific fields or columns from text files, such as log files or command outputs.

awk '{print $1, $3, $NF}' file.txt

2. Print Lines Where the Last Field Matches a Pattern