Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In the Unix less tool, is it possible to jump to the next line that does not contain a certain expression?

I sometimes have to look through files that contain thousands of similar adjacent lines that, for example, all say "Computing something" and I'm interested in the next line after the current block, which does not contain the word "Computing".

share|improve this question

2 Answers 2

up vote 11 down vote accepted

Yes, this is non-match search functionality, for example:

less file.conf

then you type / and after that ! your last line should look like:

Non-match /

then type your pattern for example Non-match /^# to look for first line without beginning #

Instead of ! character you can also use Ctrl+N.

share|improve this answer
2  
+1 nifty, never heard of that –  sleske Oct 2 '10 at 11:21
    
This is perfect. Couldn't have expected a better answer. –  dehmann Oct 3 '10 at 5:30

As an addition to Casual Coder's answer:

You could also filter out the lines altogether:

<logfile grep -v mypattern |less 

The disadvantage is that you have to quit and restart grep to change the pattern; the advantage is that the lines you don't want to see are hidden, which makes it easier to spot interesting patterns in the lines that you are interested in.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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