Linux terminal on a Ubuntu laptop.

Using the revolution Command about Linux

Linux terminal on a Ubuntu laptop.
Fatmawati Achmad Zaenuri/Shutterstock

"rev filelist.txt" in a terminal window.

"ls | rev | cut -d'.' -f1 | rev | sort | uniq -c" in a terminal window.

"echo 'Separate the last word' | rev | cut -d' ' -f1 | rev" in a terminal window.

Since we taken out the initially word of this reversed string, we trimmed off the last word of the original string. The last word of the sentence was “word, ” and it’s printed out for us.

Sometimes you have to go backward to go forward. And you usually go forward fastest as part of a team.

Linux’s rev command reverses strings of text. This command can operate either on provided text or a file, and it seems deceptively simple. But like many command-line utilities, its real power becomes apparent when you combine it with other commands.

Let’s look at the file:

"rev" used with "stdin" in a terminal window.

If you type some text and press Enter, it makes rev print the string in reverse-unless you provide it with a palindrome, of course.

Contents of filenames.txt in less in a terminal window.

The rev command is one of those simple Linux utilities that, at first glance, appears to be something of an oddity. It performs a single function: it reverses strings. And apart from being able to print a quick help page ( -h ) and show you its version number ( -V ), it doesn’t accept any command-line options.

The command is similar to the last one: again, it uses rev twice. The differences are lying in the way the cut demand is used to pick portions of this text.

This kind of command pieces the last figure off the thread of textual content. This could be helpful to remove punctuation. We need to operate the cut demand to deprive the character.

"echo 'Remove punctuation.' | rev | cut -c 2- | rev" in a terminal window.

So , revolution reverses strings, and that’s this? No versions or choices? Well, it all depends. Yes, they have no mixtures, but zero, that’s scarcely all. This kind of tutorial demonstrates how to combine this for strong operations.

That will put a concluding touch to it, put the -c (count) command-line option to the uniq demand.

The details of the record are viewed for us in less .

"rev filelist.txt | cut -c 2- | rev | cut -c 2-" in a terminal window.

Used on the command line with no other parameters, rev takes any typed input, reverses it, and then prints it in the terminal window. It keeps doing this until you hit Ctrl+C to exit.

"less filenames.txt" in a terminal window.

"ls | rev | cut -d'.' -f1 | rev | sort | uniq" in a terminal window.

Here’s an example using piping of input that calls rev twice.

Add rev to your repertoire of go-to commands, and you’ll soon be using it to simplify otherwise complicated command sequences.

You can use echo to pipe text to rev .

That’s a pretty nifty one-liner!

The process is straightforward:

The filenames are listed for us without the quotation marks.

We can use a similar trick to return the last word of the collection.

We now get a sorted list of the different file types in the current directory with a count of each.

Let’s break that down.

Filenames without quotation marks in a terminal window.

Here’s a command that returns a sorted list of every record extension in the modern directory. By using five distinctive Linux orders.

Let’s say we now have a file incorporating a list of filenames, and the filenames are in quotation grades. We want to remove the quotation grades from the filenames.

You can also employ rev to reverse the contents associated with an entire record of textual content, line by line. In this example, we have a file that contains a list of filenames. The file is called “filelist. txt. ”

The command breaks down like this:

Here’s the command breakdown:

When you use rev as a building block in more complicated command sequences, it really starts to show its worth. rev is among a group of commands (like tac and yes ) that are facilitators. It’s easier to appreciate their usefulness when you see how they make the use of other commands more efficient.

"rev" with a palindrome in a terminal window.

"echo one two three | rev" in a terminal window.

Each line is read from the file, reversed, and then imprinted to the terminal window.

Because we trimmed off the first character from the reversed string, we trimmed off the previous character of your original thread. Yes, you may do this with sed or perhaps awk , but this can be an easier format.

We can eliminate the punctuation out of both ends of each channel with the next command. This kind of command uses both rev and cut 2 times.

You May Also Like


You simply Need to Remove a Disc Once to Securely Get rid of It

The right way to Rip Dvd videos with VLC

Lots of Android Programs Will Lose Features or Go away from the Perform Store In the near future


Arrangement Email Notices for Dell Server Equipment Alerts

Leave a Reply

Your email address will not be published. Required fields are marked *