← All commands
Topic hub Text Processing
Windows Linux Text Processing

Windows type (awk — no equiv) equivalent in Linux

A powerful text-processing tool that splits lines into fields and lets you extract, transform, and report on structured text.

Windows type (awk — no equiv)
Linux equivalents
Debian/Ubuntu same command
awk
Fedora same command
awk
Arch same command
awk

Overview

What this command does

A powerful text-processing tool that splits lines into fields and lets you extract, transform, and report on structured text.

Migration tip: awk is a mini programming language. $1, $2, $3 refer to space-separated columns. $NF is always the last column. Incredibly useful for log files and CSV data.

Practical tasks

Common use cases

Process and extract columns from structured text

A powerful text-processing tool that splits lines into fields and lets you extract, transform, and report on structured text.

awk '{print $1}'

Print first column

awk '{print $NF}'

Print last column

awk -F ',' '{print $2}'

Use comma as separator (CSV)

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

awk -F ':' '{print $1}' /etc/passwd
awk '{print $1}' /var/log/nginx/access.log
awk '{sum += $1} END {print sum}' numbers.txt

Walkthrough

Examples with explanations

# No direct Windows CMD equivalent

# Print usernames from /etc/passwd:
awk -F ':' '{print $1}' /etc/passwd

# Print IPs from log (column 1):
awk '{print $1}' /var/log/nginx/access.log

# Sum a column of numbers:
awk '{sum += $1} END {print sum}' numbers.txt

Reference

Common options and variations

Command or optionUse
awk '{print $1}'Print first column
awk '{print $NF}'Print last column
awk -F ',' '{print $2}'Use comma as separator (CSV)
awk '/pattern/ {print}'Print lines matching pattern
awk 'NR>1'Skip header (first line)

Distro differences

Debian/Ubuntu vs Fedora vs Arch

This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command awk Same command on this distribution.
Fedora same command awk Same command on this distribution.
Arch same command awk Same command on this distribution.

Keep learning

Related Text Processing commands