What does `cut` do, and when do you prefer `awk` instead?
BeginnerConceptText processing: grep, sed, awk, cut, sort, uniq
Answer
cut extracts fields by a single-character delimiter (-d, -f) or by character positions (-c).
cut -d: -f1,7 /etc/passwd
cut -d, -f2- users.csv # field 2 to the end
cut -c1-19 app.log # timestamp prefix
cut treats every delimiter as a field boundary, so runs of spaces (like ps or df output) produce empty fields. awk splits on runs of whitespace by default, so for whitespace-aligned output use awk '{print $2}'.
More on Text processing: grep, sed, awk, cut, sort, uniq
What are the most useful `grep` flags?BeginnerWhat is the difference between basic, extended and Perl regular expressions in grep?IntermediateWhat are the core `sed` commands you use in automation?BeginnerWhy does `sed -i` behave differently on macOS and Linux?IntermediateHow do you use variables inside a `sed` expression safely?AdvancedWhat is the structure of an `awk` program?Beginner