Less (Unix)
From Wikipedia, the free encyclopedia
- The correct title of this article is less. The initial letter is shown capitalized due to technical restrictions.
Less | |
Less output in a x-terminal |
|
Developer: | Mark Nudelman |
---|---|
Latest release: | 394 / 3 Dec 2005 |
OS: | Cross-platform |
Use: | system utility |
License: | GPL |
Website: | [1] |
less is a program on Unix and Unix-like systems used to view (but not change) the contents of a text file one screen at a time. It is similar to more, but has the extended capability of allowing both forward and backward navigation through the file. Unlike vi (which can also be used to view files), less does not need to read the entire file before starting, resulting in faster load times with large files.
Contents |
[edit] History
less was initially written by Mark Nudelman during 1983-85, in the need of a version of more able to do backward scrolling of the displayed text. The name came from the joke of doing "backwards more". less is now part of the GNU project and it is included in most Unix systems.
[edit] Usage
less can be invoked with options to change its behaviour, for example, the number of lines to display on the screen. These options may vary from one Unix to another. While less is displaying the file, various commands can be used to navigate through the file. These commands are based on those used by both more and vi. It is also possible to search for character patterns in the file through an incremental search.
By default, less displays the contents of the file to the standard output (one screen at a time). If the output is redirected to anything other than a terminal, for example a pipe to another command, less behaves like cat.
The command-syntax is:
less [options] <file_name>
[edit] Frequently used options
- -g: Highlights just the current match of any searched string.
- -I: All the searches will be case insensible.
- -M: Shows browsing information.
- -N: Shows line numbers (handy for sourcecode viewing).
- -S: Disables line wrap (long lines can be seen by side scrolling).
[edit] Frequently used commands
- Arrows/PageUp/P.Down/Home/End keys: Navigation.
- ng: Jump to line number n.
- /pattern: (slash) Search for pattern. Regular expressions can be used.
- n: Go to next match (after a successful search).
- N: Go to previous match.
- mletter': Mark the current position (bookmark) with letter.
- 'letter: (single quote) Return to position letter.
- s: Save current content (got from another program like grep) in a file.
- =: (equal) File information.
- h: Help.
- q: Quit.
[edit] Examples
less -M readme.txt #Read "readme.txt". file * | less #Easier file analisis. grep -rin void *.c | less -SI -p void #Easier a heavy search of "void".
[edit] External links
Unix command line programs (more) | |||
File and file system management: | cat | cd | chmod | chown | chgrp | cp | du | df | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rm | rmdir | split | touch | tree | ||
Process management: | anacron | at | chroot | crontab | kill | killall | nice | pgrep | pidof | pkill | ps | sleep | screen | time | timex | top | wait | ||
User Management/Environment: | env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | wall | who | whoami | write | ||
Text processing: | awk | cut | diff | ex | head | iconv | join | less | more | nkf | paste | sed | sort | tail | tr | uniq | wc | xargs | ||
Shell programming: | echo | expr | printf | unset | Printing: | lp |
Communications: inetd | netstat | ping | rlogin | traceroute |
Searching: find | grep | strings |
Miscellaneous: banner | bc | cal | man | size | yes |