Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


use less | 16 comments | Create New Account
Click here to return to the 'use less' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
use less
Authored by: el.tyde on May 11, '08 05:46:46PM

While I really like Safari's improved Find interface, there is one signifcant disadvantage in using it for searching text files: it doesn't handle multi-megabyte text files very well. And to some extent, vi(m) is also somewhat slow with large files.

Textmate and other GUI text editors are great overall, but why not use a tool that is pre-installed on every OS X system. So for searching large files, and still having the benefit of your search-pattern highlighted, you should ideally use the "less" utility via Terminal. less is a pager, it loads one page at a time for display, so it is instantaneous in working with enourmously huge files (virtually no size limit). It's quite simple to use; in Terminal type (without the brackets):

less [filepath/yourfilename]

... then to search within your file, type:

/yoursearchpattern

... to go forward, backward, within your file (while still in search-highlight mode) type:

n, or N

... AND, you have the added benefit of being able to make use of some simple regular expressions to make your searches more powerful (in Safari or TextEdit, you can't).

less also holds your search-patterns in memory, if you have not exited your file; so to see or edit your previous searches, just use up-arrow, or down-arrow, after typing / (ie. "slash", to do a search).

--
So remember, less is more.



[ Reply to This | # ]