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

You must log in to answer this question.

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