cut -d, -f1,3 users.csv`cut` is fast and simple for delimited text when quoting rules are uncomplicated.
Column extraction, sorting, deduplication, character translation, file combining, and list comparison.
Extract and assemble delimited fields.
cut -d, -f1,3 users.csv`cut` is fast and simple for delimited text when quoting rules are uncomplicated.
cut -c1-8 ids.txtCharacter mode is handy for fixed-width text formats.
cut -d, --complement -f2 users.csvUseful when one noisy column needs to be removed.
paste names.txt emails.txtThe nth line of each file is merged into a single output row.
paste -d, names.txt emails.txtUseful for building ad hoc CSV-like output.
Sort text and collapse duplicate lines.
sort names.txt`sort` is often the first step before `uniq` or `comm`.
sort -r names.txtCommon when listing highest values or newest versions first.
sort -n numbers.txtWithout `-n`, numbers are compared lexicographically as strings.
sort -h sizes.txtGreat for commands like `du -h` and capacity reports.
sort -k2,2 file.txtField sorting is essential for tabular command output.
sort -u names.txtEquivalent in effect to `sort | uniq` for many workflows.
sort access.log | uniq -cRemember that `uniq` only collapses adjacent duplicates, so sorting first is common.
sort file.txt | uniq -dGreat for spotting repeated entries or duplicates in lists.
Translate, delete, and normalize characters.
tr '[:lower:]' '[:upper:]' < input.txtCharacter classes make case conversions portable.
tr '[:upper:]' '[:lower:]' < input.txtUseful for normalization before comparison or counting.
tr -d '0-9' < file.txtCharacter deletion is useful for quick sanitization tasks.
tr '
' ' ' < lines.txtUseful when flattening simple lists into a single line of text.
tr -s '
' < file.txtCan help normalize output before diffing or exporting.
Compare two sorted files and merge common keys.
join users.txt departments.txtBoth input files should usually be sorted on the join field first.
join -1 2 -2 1 left.txt right.txtUse `-1` and `-2` to choose the join field in each file.
comm -12 <(sort file1.txt) <(sort file2.txt)`comm` compares two sorted inputs and can suppress selected columns.
comm -23 <(sort file1.txt) <(sort file2.txt)Useful for simple set-difference operations in shell scripts.
comm -13 <(sort file1.txt) <(sort file2.txt)Great for comparing inventories, exports, or generated lists.