When viewing text files at the Linux command line, less is the program to use.

by Carter Toni

When examining text files in the terminal, using the less utility makes the process much faster.

Text files are the one thing that can be relied upon to be present on any Linux-based computer system. A great number of them. Readme files, configuration files, papers, and more.

To read about more scripts linpeas and all visit.

A text editor is most likely what you use to open text files the vast majority of the time. Reading text files can also be done in a way that is both quicker and, in my opinion, more accurate. This is accomplished through the application known as less. less is a textfile viewer for the command line that comes preinstalled with all Linux distributions (at least all of the ones I’ve used), and it has a number of features that can be helpful.

You shouldn’t let the fact that it’s a command-line tool make you nervous in any way. less is incredibly user-friendly and has a steeply sloping learning curve despite its ease of use.

Let’s take a look at some of the things you can accomplish with fewer resources, shall we?

Getting started

Launch a new terminal window and head to the directory that has the text file or files that you wish to examine. The next step is to execute the less filename command, where filename is the name of the file that you want to examine.

Your terminal window will be completely taken over by the file, and you will see a colon (:) at the bottom of the window. Following the colon is where you should write any of the less-specific instructions that you make use of. A little bit more on these in a second.

Getting around town

There is a good chance that the text file you are looking at has more than a few of lines; in fact, it is probably at least one page long. When you have less, there are a few different methods you can make progress in the file:

To go down a page, press the space bar or the PgDn key on your keyboard.

By hitting the Down arrow key, you can move down the page by one line at a time.

less enables you to travel backward in a file as well as forward. To accomplish this, you can either hit the Up arrow key or the PgUp key (to move up a page at a time) (to move up one line at a time).

Locating the text

If you have a large text file or are looking for a particular bit of text, you may simply discover it using less. You can find a word or phrase by pressing the / key on your keyboard and then typing the word or phrase you are looking for.

Take note that less’s search function looks for matches in both lowercase and uppercase letters. When you type “the silence,” you don’t get the same result as when you type “The Silence.”

less will also highlight any words or phrases that are relevant to your search. That is a very good touch that will make it much simpler for you to scan through the material.

To locate the following instance of the word or phrase, you can discover it by pressing the n key on your keyboard. To locate the instance before this one, press the letter p on your keyboard.

Leave that place immediately.

How can you exit less once you have finished reading all of the contents of a text file and have reached its conclusion? That is very simple. (If you want to exit the program at any moment, you can also hit the q key.)

As I indicated at the beginning of this piece, the less text editor is simple to work with. After you’ve had some experience with it, you’ll wonder how you ever got along without it.

Related Posts

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.