Reverse Text With rev

Reverse the characters of every input line with a small built-in filter.

macOSTerminalscriptingLow risk
Run echo "cmdcv" | rev to print the characters backwards.

01Command

Command
$ echo "cmdcv" | rev

02What it does

rev reads lines and outputs each one with its characters reversed, a surprisingly handy way to check palindromes or to process fixed-width fields from the end. It is included by default on macOS and available in util-linux on Linux.

03Risk

RiskLow risk
CompatibilitymacOS (built-in)
!Warning: It reverses bytes, not grapheme clusters, so multi-byte emoji can be mangled.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • rev(1) — FreeBSD manual
    FreeBSD · technical · 2026-09-20
    Evidence: Reverses the order of characters in each line; the basis of the macOS rev.

Last verified: 2026-09-20 · Category: Developer

06Related solutions