command: less

Discussion in 'Beginner Tutorials' started by Rob, Nov 3, 2011.

  1. Rob

    Rob Administrator Staff Member

    Messages:
    573
    Likes Received:
    184
    Trophy Points:
    43
    The less command is helpful to view a screenfull of a text file. If you're familiar with vi/vim, you can use the direction keys to go down (j) or up (k).. you can also ctrl-f or ctrl-b to go up/down a full screen.. or just use the keyboard's arrow keys..


    Example:

    I've filled a file named 'example' with Lorem Ipsum text:
    Screenshot-5.png
    DevynCJohnson likes this.
  2. Rob

    Rob Administrator Staff Member

    Messages:
    573
    Likes Received:
    184
    Trophy Points:
    43
    Once in your less screen, search downwards with / or upwards with ? (just like in vi/vim!)
    DevynCJohnson likes this.
  3. lanlanlangzi

    lanlanlangzi New Member

    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    this command is very useful for browse file's content.
  4. Stefano Messicano

    Stefano Messicano New Member

    Messages:
    88
    Likes Received:
    1
    Trophy Points:
    0
    You can also open several files at the same time so you can navigate from one file to next without closing it first. If you want to open several files, just give all the file names at once: less file1 file2 file3.
    When viewing several files at the same time, you can use :n for examining the next file and :p for the previous file.
    Amit_*nix likes this.
  5. yezrach

    yezrach New Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    very useful for big file, not like vi / vim.
  6. KenJackson

    KenJackson Active Member

    Messages:
    129
    Likes Received:
    28
    Trophy Points:
    28
    I find that I very frequently use the -S switch to truncate sloppy long lines instead of letting them wrap. So I put an alias in my ~/.bashrc file:
    Code:
    alias lesss='less -S'
    That allows me to type:
    Code:
    lesss sloppy-long-lines.txt
    Note that you can also type -S while viewing the file to toggle truncation and wrap.
  7. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,139
    Likes Received:
    385
    Trophy Points:
    83
  8. reza77

    reza77 Guest

    hi.
    very good.
    thank

Share This Page