rev(1)
Reverse lines characterwise.
UbuntuDebianFedoraArch
Synopsis
rev [FILE]...Description
The rev command reads each line of input and outputs it with characters in reverse order. It processes files line by line, preserving the newline at the end of each reversed line.
If no files are specified, rev reads from standard input. Multiple files are processed in sequence, with each line reversed independently.
Common options
| Flag | What it does |
|---|---|
-h, --help | Display help message and exit |
-V, --version | Display version information and exit |
Examples
Reverse a simple string; outputs 'olleh'
echo 'hello' | revReverse each line in the hostname file
rev /etc/hostnameReverse multiple lines; outputs 'cba', 'fed', 'ihg'
echo -e 'abc\ndef\nghi' | revReverse lines from both file1.txt and file2.txt
rev file1.txt file2.txtReverse each filename from a directory listing
ls | revReverse twice to verify the operation (output matches original)
cat script.sh | rev | rev