Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I sometimes have to look through files that are several gigs and have noticed that finding what I am looking for with grep is much faster than with less. Why could that be? I am talking about looking for a certain tag/word, not even any complicated regex.

share|improve this question
    
Not an answer, but have you considered using grep and then a pipe to pass the results onto less? – ridogi Jan 12 '10 at 7:19
1  
Yes, I usually use grep with -A/B/C to get some context around what I am searching for but sometimes I need more flexibility as I am looking at log files and need to be able to scroll around and incrementally search from there on/before – naumcho Jan 12 '10 at 21:18

By default, 'less' calculates line numbers, which can slow it down. Try using the '-n' option to suppress line number calculations and see if that speeds things up.

share|improve this answer
2  
I think the line counting happens once grep has found your match - then you see "Calculating line numbers" and it takes a while before it lets you do anything, but you can cancel that with ctrl+c. It doesn't look like the -n helps with the actual search speed. – naumcho Jan 12 '10 at 21:25
    
That did the trick for me. Noticed a huge difference (as in tens of seconds vs instantaneous response) when opening a nearly 10GB log file and hitting shift G to get to the end of the file. – Marcello Romani Sep 4 '15 at 9:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .