Closed Captioning Closed captioning available on our YouTube channel

How to use the rev command: 2-Minute Linux Tips

Network World | Jul 12, 2019

In this Linux tip, learn the command that reverses text – the rev (reverse) command. At first glance, this command may not seem helpful. But, there are times that it can be quite useful.

Copyright © 2019 IDG Communications, Inc.

Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at a command that reverses text – the rev (reverse) command. As odd as this command might first appear, there are times that it can be quite useful
First, let’s look at a very simple rev command. This command takes that is piped to it and reverses it character by character.
The rev command can also reverse lines from a text file. The two commands on this line display the first 3 lines in the states file and then reverse those lines.
Now let’s look at a command that could actually be useful. In this command we remove the state abbreviations from each line like those just shown. We do this by using rev twice and using cut to omit the first 5 characters on each line while it’s reversed. If you had to do something like this for 111,000 lines of text, you’d probably love this trick.
Basically, what’s happening here is each line is going through changes like this:
That’s your Linux tip for today.
If you have questions or would like to suggest a topic, please add a comment below.
And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube. If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and
Featured videos from