GNU coreutils Commands
ls, cp, mv, chmod and the other basic file utilities.All GNU coreutils pages
- sort -k: sort a file by a column (numeric, reverse, by delimiter)sort -t, -k3,3n sorts lines by one column: n for numbers, r for reverse, -h for sizes. Why -k2 without an end is wrong, and how to check order with sort -c.
- sort | uniq -c | sort -rn: count duplicate linessort file | uniq -c | sort -rn counts how often each line occurs, most frequent first. uniq only merges adjacent lines, so sort first. Real output for logs.
- split: split a large file into smaller files by lines or sizesplit -l 1000 or split -b 100M cuts a large file into numbered pieces; cat part_* joins them again. Options for line-safe chunks, suffixes and extensions.
- wc -l: count the lines in a filewc -l file counts the lines in a file; wc -l < file prints only the number. Why a last line without a newline is not counted, and counting many files at once.