Frequently Asked Question
When should I reach for cut, and when for awk?
cut extracts columns by position or by single-character delimiter. cut -d: -f1 /etc/passwd pulls out the username (field 1, colon-separated) from each
line; cut -c1-10 file.txt pulls characters 1–10 from each line. It is small,
fast, and obvious, and that is its niche. For trivial column extraction with a
clean single-character delimiter, cut is the right tool.
But cut cannot handle runs of whitespace as a single separator, cannot do
arithmetic, cannot filter rows by content, and cannot reorder columns. The
moment any of those is required, switch to awk. awk '{ print $1 }' is the
idiomatic way to pull the first whitespace-delimited column (which cut cannot
easily do because of variable spacing). awk -F: '{ print $1 }' matches the cut
example above and is no slower. As a rule of thumb: use cut for one-off
column-by-position extraction on tidy CSV-like data; use awk for anything that
involves a non-trivial separator, a filter, or computation.