less PDF Print E-mail

less

This command displays parts of a file at request so you can read one screen or one additional at a time instead of the whole file flying by. Also, an advantage of less is that it does not read the whole file before output is placed on the screen. This means that the actual usage of less is faster than more for example. This speed difference is most evident in larger files. Options Space scroll forward one line at a time D scroll forward ½ screen at a time Return scroll forward one line at a time B scroll backward one screen U scroll backward ½ screen at a time Y scroll backward one line g scroll to beginning of text G scroll to the end of text H help :n show next file ;p show last file /textpattern search for a text pattern ?textpattern search backward for a text pattern The file used for an example is called data. The command to use for normal operations is the less command followed by the filename: less data acpi adduser.conf adjtime aliases aliases.db alsa alternatives anacrontab apm apt at.deny bash.bashrc bash_completion bash_completion.d bogofilter.cf bonobo-activation calendar cdrecord chatscripts console console-tools cron.d cron.daily data The example shows the output of the less command. The output stops at the end of the first page and the word data, shown in the example, has a cursor on it that is blinking. It is waiting for input to go to another screen line, etc. When you enter commands it will take place from this blinking cursor. This is important to consider when you are doing a search because you may want to search either forward or backward. If you wanted to search the document for conf files or the text string conf you would use this command: /conf Here is the output; notice it stops on the first conf file located. adduser.conf adjtime aliases aliases.db alsa alternatives anacrontab apm apt at.deny bash.bashrc bash_completion bash_completion.d bogofilter.cf bonobo-activation calendar cdrecord chatscripts console console-tools cron.d cron.daily cron.hourly :


If you choose the command n at this point you will see all the next conf files highlighted. See the output. Again notice the colon at the end waiting for a command.



debconf.conf

debian_version

default

defoma

deluser.conf

dev.d

devfs

dhcp3

dictionaries-common

discover.conf

discover.conf-2.6

discover.conf.d

discover.d

dm

dpkg

emacs

environment

esound

evms.conf

fdmount.conf

firestarter

fonts

foomatic

:


Another common way of using less, is to pipe a file into less for the same output.


cat data | less


This command gives you the same output as the first command. The pipe symbol is used to input the data file through less.