awk

Pattern-scanning & text-processing language.

KaliParrotLinuxpassive

pkg: gawk

awk processes text by fields and patterns — extract columns, compute and reformat output in pipelines.

Syntax

awk '{print $N}' [file]

Example

ss -tlnp | awk '{print $5}'

Prints the 5th column (local address:port) from each line.

Options & flags

What each switch does. Toggle them in the builder below to assemble a command.

'{print $N}' <value>Print field N (whitespace-separated).
-F <:>Set the field separator.
'/re/{...}' <value>Run an action on lines matching a regex.
-v <x=1>Pass a variable into the program.

Command builder

Tick options (and fill any values) to build a ready-to-copy command.

awk

Usage examples

awk -F: '{print $1}' /etc/passwd

Print usernames (colon-separated).

ss -tlnp | awk '{print $5}'

Extract local address:port column.

Advantages
  • Powerful field processing
  • Ubiquitous
Disadvantages
  • Mini-language to learn
  • Awkward for complex logic
Tags
#text#scripting

Official docs: GNU awk

Related commands

Frequently asked questions

What is awk used for?
awk processes text by fields and patterns — extract columns, compute and reformat output in pipelines.
What is an example awk command?
A common example is: ss -tlnp | awk '{print $5}' — Prints the 5th column (local address:port) from each line.
Is awk part of Kali Linux?
Yes. awk ships with Kali Linux (and Parrot OS). If missing, install it with: sudo apt install gawk.
What category of security tool is awk?
awk is a Core Linux tool with a passive-risk profile when run against a live target.

Try recon tools live

Run real scans against a domain you control, stage by stage.

Open the lab →