Linux more and less command Options

Unix and Linux more command also displays the content of a file. Difference between is that, in case of larger files, ‘cat’ command output will scroll off your screen while ‘more’ command displays. Output one screen full at a time.

Now we can used in ‘more’ command to scroll the page :

1.Press Enter key to scroll down page line by line.
2.Space bar to go to next page.
3.b key to go to the backward page.
4./ key let’s you search the string.

Sample Syntax of more command :

# more <file name>

Like example of more command :

more /var/log/syslog

Look at the above snapshot, in the left corner it shows 2%, which indicates that 2% page is displayed.

If you scroll down use ‘space’ button, next page will be displayed. If you want to go to the last or backward page use ‘b’ key.

Here: The ‘more’ command can’t be used to display binary files.

Linux more options

1.more -num Limits the line displayed per page.
2.more –d Displays user message at right corner.
3.more –s Squeeze blank lines.
4.more +/string name It helps to find the string.
5.more +num Used to display the content from a specific line.

Linux less command

Unix or Linux system ‘less’ command is same as ‘more’ command but include some more features.

sample syntax of less command :

# less <file name>

Like example of less command :

# less /var/log/syslog

See, we have given the command “less /var/log/syslog”. The file left corner, name of the file is displayed.

Linux to Find A String

The Linux system particular string is searched by typing forward slash (/) and then followed by the string name, at place of file name in the lower left corner of the terminal box.

Sample syntax of find command :

/string name

Like example of find command :


See, we want to find string ‘add’ hence we have typed “/add” at the lower left corner.
shows the output of command “/add”. The string ‘add’ will be automatically highlighted.

less Command Navigation Keys

The Unix and Linux system less command have navigation keys similar to the vim editor. Now you have a look on some of the navigation keys and other operations of less command.

Search Navigation

Search navigation keys will help you in forward and backward search.

Forward search

1./ : search for a pattern for the next occurence
2.n : search for next match
3.N : search for previous match

Backward search

1.? : search for a pattern for the next occurence
2.n : for next match in backward direction
3.N : for previous match in forward direction

Search path

1.Forward : /\/home\/sssit\/
2.Backward : /home/sssit

Screen Navigation

1.Ctrl + f : forwards one window
2.Ctrl + d : forwards half window
3.Ctrl + b : backwards one window
4.Ctrl + u : backwards half window

Line Navigation

to move forward or backward line by line
1.j : forward by one line
2.k : backward by one line

Other Navigations

1.G : used to go to end of the file
2.g : used to go to start of the file
3.q or ZZ : to exit

Count Keys

1.10j : 10 lines forward
2.10k : 10 lines backward

Marked Navigation : mark current position with letter ‘a’
2.a : go to marked position

Multiple File

by passing arguments in the same line
less file1 file2
while viewing file1 go to file2
ess file1

to navigate between files when more then two files are opened

1.n : go to next file
2.p : go to previous file

Leave a Reply