Results for “Sorting & joining records”
Small, practical examples. Search by task or narrow things down below.
Count repeated lines after sorting
Linux Commands: Group identical lines before uniq -c, then normalize its leading padding.
Linux Commands✓ Tested
Sort records by a delimited field
Linux Commands: Select the exact sort key to avoid including later columns.
Linux Commands✓ Tested
Check whether a file is already sorted
Linux Commands: Use sort -C for a quiet status check that does not rewrite the file.
Linux Commands✓ Tested
Find lines common to two sorted files
Linux Commands: Use comm -12 to suppress the two columns of unmatched lines.
Linux Commands✓ Tested
Find lines unique to the first sorted file
Linux Commands: Use comm -23 to retain only records absent from the second input.
Linux Commands✓ Tested
Join two sorted files by a shared key
Linux Commands: Use join for sorted, simple delimiter-separated records with one row per key.
Linux Commands✓ Tested
Print only duplicate values
Linux Commands: Use uniq -d after sorting to report each repeated value once.
Linux Commands✓ Tested
Sort lines by numeric value
Linux Commands: Use sort -n so 10 sorts after 2 instead of before it.
Linux Commands✓ Tested
Sort values in descending order
Linux Commands: Combine numeric sorting with reverse order.
Linux Commands✓ Tested
Sort version-like labels naturally
Linux Commands: Use GNU version sort to compare embedded digit runs numerically.
Linux Commands✓ Tested
Preserve equal-key order while sorting records
C++: stable_sort retains encounter order for records whose selected sort keys compare equal.
C++✓ Tested
Count newline-terminated records
Linux Commands: Count newline-terminated records using GNU/Linux commands in an empty practice directory.
Linux Commands✓ Tested