Both more
and less
are text paging utilities in Linux and Unix-like systems, but they differ significantly in functionality and flexibility:
Origin and Philosophy
- more: The original Unix pager, developed in the 1970s
- less: Developed later (1980s) as an improved version of
more
, playing on the phrase “less is more”
Key Differences
Navigation Capabilities
more:
- Only allows forward navigation (can’t go back up)
- Limited to scrolling down through a file
- Once you scroll past content, you can’t view it again without restarting
less:
- Supports bidirectional navigation (both forward and backward)
- Can scroll up/down, page by page or line by line
- Allows jumping to the beginning or end of a file
Memory Usage
- more: Loads the entire file into memory at once, which can be problematic for very large files
- less: Loads files incrementally, only reading portions needed for display, making it more efficient for large files
Search Capabilities
- more: Limited search functionality (only forward searching)
- less: Robust search capabilities, including:
- Forward and backward searching
- Regular expression support
- Case-sensitive/insensitive options
- Highlighting of search results
Interactive Features
- more: Basic set of commands
- less: Extensive command set, including:
- Marking positions in the file for easy return
- Multiple file support with ability to switch between files
- Ability to edit the file being viewed (by launching an editor)
- Real-time file monitoring (similar to
tail -f
)
Command Syntax Examples
# Basic usage
more filename.txt
less filename.txt
# Using with pipes
command | more
command | less
# Following file changes (only in less)
less +F logfile.txt
# Searching (while viewing)
# In more: /pattern (forward only)
# In less: /pattern (forward) or ?pattern (backward)
Exit Behavior
- more: Automatically exits when it reaches the end of the file
- less: Stays open until you explicitly quit (by pressing ‘q’)
When to Use Which
Use more when:
- You need a simple, lightweight pager
- You only need to read through a file once from top to bottom
- Working on very old Unix systems where
less
might not be available
Use less when:
- Working with large files
- Need to search and navigate back and forth
- Monitoring log files in real-time
- Require advanced features like multiple file handling
The phrase “less is more” is particularly apt here, as less
provides more functionality while using fewer system resources for large files.