less is more
If you work with text files in Linux, you've likely encountered situations where you need to examine file contents without modifying them. The less
command is one of the most versatile tools for this purpose, offering significantly more features than its predecessor, more
.
What is 'less'?
Despite its name suggesting otherwise, less
is actually more powerful than the more
command. The name comes from the Unix philosophy phrase "less is more." It's a pager program that allows you to view text files one screen at a time, with robust navigation capabilities.
Key Features
- Bidirectional scrolling: Unlike
more
, you can scroll both forward and backward through files - Search functionality: Press
/
to search forward or?
to search backward - Multiple file support: Open multiple files and switch between them
- Line numbers: Toggle line numbers with the
-N
option - No file size limitations: Works efficiently with files of any size
Basic Usage
less filename.txt
Navigation Commands
While viewing a file with less
, you can use these keyboard shortcuts:
Space
orf
: Forward one pageb
: Backward one pageg
: Go to first lineG
: Go to last lineq
: Quit less
Why Choose 'less'?
The less
command doesn't load the entire file into memory, making it perfect for viewing large log files or documentation. It's also part of most Linux distributions by default, so you can count on it being available wherever you're working.
Next time you need to examine a file's contents in Linux, remember: with less
, you can do more!
- ← Previous
htop - Next →
ncdu - NCurses Disk Usage