Default Image

Months format

Show More Text

Load More

Related Posts Widget

Article Navigation

Contact Us Form

404

Sorry, the page you were looking for in this blog does not exist. Back Home

At the Linux Command Line, Less is the Application of Choice for Examining Text Files

    Using the less program in the terminal speeds up the process of reviewing text files.

    Only text files can be absolutely guaranteed to exist on every Linux machine. There were a lot of them. Documents such as "readme.txt" and "config.txt"

    To learn more about linpeas and other scripts, check out.

    The great majority of the time, you will utilize a text editor to read text files. I've also seen a faster and more accurate method for reading text files. The program less is used for this purpose. less is a command line text file viewer with a variety of useful features that comes preinstalled with all Linux distributions (at least all of the ones I've tested).

    Linux Command Line



    Just because it's a command-line tool doesn't mean you should be wary about using it. Although less is quite straightforward to use, its learning curve is somewhat severe.
    Let's have a look at what we can do even if we have to make do with less money.


    The First Steps

    Open a new terminal window and navigate to the folder containing the text files you want to review. The next step is to run the less command followed by the name of the file you wish to inspect, in this case, filename.

    A colon (:) will appear at the bottom of your terminal window when the file has finished loading. In the space that comes after the colon, type any supplementary, less detailed instructions you need. A moment while I elaborate on these a bit further.

    How to Navigate the City

    The text file you're viewing is likely to be longer than a few lines; in fact, it's probably at least one page in length. When resources are limited, you can still make headway through the document in a few different ways:

    Using the space bar or the PgDn key on your keyboard will take you down a page.

    You can scroll down the page by one line at a time with the Down arrow key.

    You may go backwards in a file with less as well as forwards. You can use the Up arrow key or the PgUp key (to advance by one page) to do this (to move up one line at a time).


    Seeking the Document

    Finding the exact text you're looking for in a large text file may be as easy as using less. Simply enter the word or phrase you're looking for and hit the / key on your keyboard to locate it.

    Keep in mind that less's search function will try to find a match regardless of case. The outcome of typing "the silence" is different from that of typing "The Silence."

    Any search terms that less finds will be highlighted for you. That's a nice touch that'll make it much easier to skim the content and get what you need.

    Just hit the n key on your keyboard to see where the word or phrase appears next. Use the letter p on your keyboard to jump to the previous occurrence.


    It is imperative that you promptly depart from that location.

    When you've finished reading a whole text file, how can you minimize the number of times you have to use the exit button? That's an easy fix. (At any time, you can press the q key to quit the program.)

    The less text editor is user-friendly, as I mentioned at the outset of this essay. You won't know what you did without it until you try it out for yourself.

    No comments:

    Post a Comment