
How to Use rev and tac and Other Text Reversers Step by Step
Reverse characters with rev and lines with tac, plus last field extraction, reverse sort, and the portable alternatives for macOS where tac is missing.
Tag
6 posts

Reverse characters with rev and lines with tac, plus last field extraction, reverse sort, and the portable alternatives for macOS where tac is missing.

Remove duplicate lines from a file while keeping the original order: the awk '!seen[$0]++' idiom, deduplicating by field, case-insensitively and in place.

Use fold, fmt and nl to wrap lines, reflow paragraphs and number text from the terminal, and know which one breaks words, which respects them, and why.

Decide between regex and string functions for simple text tasks: prefix, suffix, contains, split and replace, with readability, speed and safety.

Split a file by line count, size or pattern with split and csplit, name the pieces, keep headers, and split compressed streams without temporary files.

Compare two files and show only the differences with diff, cmp, comm and git diff, in unified, side-by-side and word-level views, and ignore whitespace.