You probably use less all the time, but do you use all its power? Jerry Peek shows you how to get the most out of less in the second part of his look at the less utility.
Over the years, I’ve shown a number of uses in the “Power Tools” column for less the handy pager program that has more features than more (and is the default on most Linux distros). In this column, I’ll discuss advanced search techniques, new features in less version 394, how to scroll sideways, and much more.
Changing Options Interactively
Last month, you saw how to set default options in the LESS environment variable and in a lesskey file. Many options can be reset as you’re running less. Simply type a dash, the option name string, and any argument to the option.
If the option is a toggle, its value will be toggled. For example, if you’re using less to read a manual page via man, the option -i (--ignore-case) is set by default so searches using the / command are case-insensitive. While you’re reading a manual page, typing -i or --ignore-case makes searches case-sensitive. less explains the option that’s been changed with a message Case is significant in searches(press Return). (You generally don’t need to press Return; just type the next command.)
If you type an option name that requires an argument, less immediately prompts for the argument. If you type -j, which sets the line number on the screen where the next search target will be displayed, you’ll see the prompt Target line: at the bottom of the screen. Enter the line number and press Return.
To see the description and current setting of an option, type the…
Please log in to view this content.
Not Yet a Member?
Register with LinuxMagazine.com and get free access to the entire archive, including: