Home·Terminal commands

rev

Text processing

Usage

rev [file]

Reverses the characters within each line, not the order of the lines — that is tac's job.

Common flags

FlagMeaning
nonerev has no options; pipe it through cut or paste instead

Examples

echo hello | rev

Prints olleh.

rev paths.txt | cut -d/ -f1 | rev

Grabs the last slash-separated field.

These were built to be piped together. Three joined commands are usually shorter than one that does everything.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does rev do?

Reverses the characters within each line, not the order of the lines — that is tac's job.

Q. How do I type it?

rev [file] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

1 are listed here; the full set is in man rev. This command sits under Text processing.

Related commands

man page: man rev