rev command
Shows text in reverse order, by text string or line by line
Typical usage: shell scripting, system administrationIntroduction into rev
The rev
command can be used to read data and show the reversed version. When using it with files, it will reverse the output line by line. This tool is helpful with shell scripting when some data needs to be reversed.
Installation
When rev is not installed by default, it can be added to the system using the relevant software package.
Package information for rev
Operating system | Package name | Installation |
---|---|---|
AlmaLinux | util-linux-core |
|
Arch Linux | util-linux |
|
Debian | util-linux |
|
Fedora | util-linux-core |
|
Red Hat Enterprise Linux | util-linux-core |
|
Rocky Linux | util-linux-core |
|
openSUSE | util-linux |
|
Ubuntu | util-linux |
|
Your Linux distribution using a different package? Share your feedback.
Usage
Examples using rev
Read from standard input and reverse the string 1234
echo 1234 | rev
Output: 4321
Frequently Asked Questions
What is the rev command and its purpose?
The rev command is a command-line tool on Linux to reverse text or data from a file.
Which package provides the rev command?
The command rev is provided by the util-linux or util-linux-core package.
Related and similar commands
Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to rev:
Command | Category | Summary |
---|---|---|
awk | data processing | Performs data extraction and reporting from files |
basename | files | Strips directory and file name suffix from a given path |
head | data processing | Show the first number of lines from a file |
nice | processes | Runs commands with specified priority |