To aide one’s quest for godhood in the Linux world, might I suggest an extremely handy application called “less�. Less is somewhat similar to the program “more�, but extends and adds some additional features such as:
- forward and backward movement within a file
- searching (including regular expressions) and highlighting
- watches on the end of the file (similar to tail)
- line numbers
- toggle line wrapping (useful for large log files)
- open simultaneous file
- many more (see )
To run less, simply type the following command (prompt$ = your shell prompt):
prompt$ less helloWorld.txt
Below you will find some tips on how to use less once it is up and running.
Navigation:
You can then navigate up and down through the file with the arrows, or the page-up and page-down keys.
Searching:
To initiate a search, simply press the “/� to bring up search prompt. Then either enter a string or regular expression and hit enter. Less will then highlight all matches. To keep searching through the file, simply press “/� and hit enter once more to look further for the previous phrase. HINT: Use the search feature in conjunction with the file watch command to highlight your search phrase in incoming data.
Watches:
To initiate a watch, you can issue the command “F� while running less. This will tell less to start examining the end of the file for incoming data. This can be very useful to keep an eye on raw web access or error logs, as well as system and mail logs.
Wrapping:
To toggle line wrapping, issue the command “-S� while running less. Note that once line wrapping is disabled, you can scroll left and right with the arrow keys to see the extended data.
For more information on using less, please refer to their website at: http://www.greenwoodsoftware.com/less/)
NOTE: If you don’t have less installed, see your specific distribution docs or download it from here.
Take my word for it and add the program “less� to your bag of tricks, right away.