up vote 2 down vote favorite
share [g+] share [fb]

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.

link|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
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 – user12019 Jan 12 '10 at 21:18
feedback

1 Answer

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.

link|improve this answer
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. – user12019 Jan 12 '10 at 21:25
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.