HxHippy

less

Opposite of more; view file content paginated

Overview

Allows backward movement in the file as well as forward movement. Less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi.

Syntax

less [OPTION]... [FILE]...

Common Options

-N, --LINE-NUMBERS

Causes a line number to be displayed at the beginning of each line in the display.

-S, --chop-long-lines

Causes lines longer than the screen width to be chopped (truncated) rather than wrapped.

-i, --ignore-case

Case-insensitive searching. The search ignores case by default if the pattern contains no uppercase letters.

-M, --LONG-PROMPT

Causes less to prompt more verbosely than usual, showing the percentage into the file.

+<number>

Start at the specified line number.

+/<pattern>

Start at the first occurrence of pattern in the file.

-X, --no-init

Disables sending the termcap initialization and deinitialization strings to the terminal.

-F, --quit-if-one-screen

Causes less to automatically exit if the entire file can be displayed on the first screen.

Examples

$ less /var/log/syslog

View the system log using less.

$ less -N logfile.txt

View logfile.txt with line numbers.

$ less +100 error.log

Open error.log and jump to line 100.

$ less +/ERROR access.log

Open access.log and jump to the first occurrence of 'ERROR'.

$ ls -l | less

Pipe the output of ls -l into less for paginated viewing.

$ dmesg | less

View kernel ring buffer messages using less.

viewpaginatescrollfiletextlesspager