Learn Why 'less' is Faster Than 'more' Command for Effective File Navigation

The more and less commands are essential pagers used to view text file contents one screen at a time. While both serve similar purposes, less offers superior functionality and performance compared to more, making it the preferred choice for file navigation in Unix-like systems.

Understanding the 'more' Command

The more command is a basic pager that displays file contents sequentially, originally allowing only forward navigation. Modern implementations support limited backward movement.

Basic Usage

$ more /var/log/dpkg.log
2016-12-02 11:30:45 startup archives unpack
2016-12-02 11:30:45 install python-ptyprocess:all <none> 0.5-1
2016-12-02 11:30:45 status half-installed python-ptyprocess:all 0.5-1
2016-12-02 11:30:45 status unpacked python-ptyprocess:all 0.5-1
2016-12-02 11:30:46 install python-pexpect:all <none> 4.0.1-1
...........................................................................................

Navigation and Options

Navigate using Enter (line by line) or Spacebar (page by page). Exit with q or CTRL+C.

$ more -10 /var/log/kern.log    # Show 10 lines per page
$ cat file.txt | more           # Use with pipes

Understanding the 'less' Command

The less command is an enhanced pager offering bidirectional navigation, search capabilities, and better memory management. It loads content dynamically, making it significantly faster for large files.

Basic Usage

$ less /var/log/dpkg.log

Key Features

Display line numbers with the -N option:

$ less -N /var/log/dpkg.log
      1 2016-12-02 11:30:45 startup archives unpack
      2 2016-12-02 11:30:45 install python-ptyprocess:all <none> 0.5-1
      3 2016-12-02 11:30:45 status half-installed python-ptyprocess:all 0.5-1
      4 2016-12-02 11:30:45 status unpacked python-ptyprocess:all 0.5-1
      5 2016-12-02 11:30:46 install python-pexpect:all <none> 4.0.1-1

Why 'less' is Faster Than 'more'

Performance Comparison: less vs more more ? Loads entire file ? Forward navigation only ? Limited search ? Higher memory usage ? Slower for large files less ? Dynamic loading ? Bidirectional navigation ? Advanced search ? Memory efficient ? Faster startup

Key Advantages of 'less'

  • Dynamic Loading ? Only loads the visible portion of the file, not the entire content

  • Bidirectional Navigation ? Move forward and backward through the file using arrow keys

  • Advanced Search ? Use /pattern to search forward and ?pattern to search backward

  • Memory Efficiency ? Uses significantly less RAM for large files

  • Faster Startup ? Instant display without waiting for complete file load

Navigation Comparison

Action more Command less Command
Forward one line Enter Enter or j
Backward one line Not available k or ?
Forward one page Spacebar Spacebar or f
Backward one page Limited support b
Search forward Limited /pattern
Go to beginning Not available g
Go to end Not available G
Exit q or Ctrl+C q

Common Use Cases

# View log files efficiently
$ less /var/log/syslog

# Search within file
$ less /etc/passwd
# Then use: /username to search

# View with line numbers
$ less -N script.py

# Follow file updates (like tail -f)
$ less +F /var/log/messages

Conclusion

While more is a basic pager suitable for simple file viewing, less provides superior performance and functionality. Its dynamic loading mechanism makes it significantly faster for large files, while advanced navigation and search features enhance productivity. For modern Unix systems, less is the preferred choice for efficient file navigation.

Updated on: 2026-03-17T09:01:38+05:30

193 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements