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.

I have a file with repeated lines that have particular text on them. I need to view the file content ignoring these lines.

Is there anyway I can achieve this using vi?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You can use a command like :%g/re/d to delete all the lines that match some regular expression (re).

share|improve this answer

Most vi clones (like vim) can read from standard input.

The following command will allow me to view /var/log/messages , while ignoring all lines from the 'kernel' syslog facility (These are the Firewall lines, which I want to ignore for now):

$ grep -wv "kernel:" /var/log/messages | vi -
Vim: Reading from stdin...

This will let you view the file, however you won't be editing the file. You are editing a copy of the file.

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.