Skip to content
gohacks.dev
Tooling

awk Column Extractor

Pick columns out of whitespace-aligned or delimited text, filter lines by a pattern, and get the equivalent awk and cut commands.

Free · No sign-up · Your inputs stay in your browser

Input

Extract columns like awk

Output

Columns

85 characters

awk

awk 'NR > 1 { print $1, $2, $4, $11 }' OFS='\t' file

awk splits on runs of spaces and tabs by default and ignores leading blanks; cut splits on every single delimiter, so cut -d' ' breaks on aligned output like ps or docker ps. Use awk for whitespace-aligned text and cut for CSV-like data without quoting.

Runs in this browser. Nothing you paste is sent to a server.

awk or cut

awk splits on runs of spaces and tabs by default and ignores leading blanks, which is what aligned command output needs. cut splits on every single occurrence of its delimiter, so on aligned output it returns empty fields. cut is the right tool for CSV-like data without quoting; awk for everything a person formatted with spaces. The gawk manual is the reference.

Beyond printing columns

awk is a small language: awk '{sum += $5} END {print sum}' totals a column, awk '$3 > 80' filters by value, and awk -F: '{print $1}' /etc/passwd lists users.

Share

Frequently asked questions

How do I print the last column with awk?
awk '{print $NF}'. NF is the number of fields on the line, so $NF is the last one and $(NF-1) the one before.
How do I use a different separator in awk?
awk -F, for commas, -F: for colons, or a tab given with -F and a quoted tab escape. Set OFS to change the separator between printed fields.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools