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?

link|improve this question
feedback

2 Answers

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).

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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