LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I remove lines that have more than one of a certain character in them? (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-remove-lines-that-have-more-than-one-of-a-certain-character-in-them-697309/)

SentralOrigin 01-14-2009 01:29 PM

How do I remove lines that have more than one of a certain character in them?
 
I have a file with a few thousand lines and I'd like to remove all the lines that have more than 1 asterik (the * character) in it. So if it has 2 or more in a single line, I'd like the line removed (double d command in vi)

nflenz 01-14-2009 01:35 PM

Quote:

Originally Posted by SentralOrigin (Post 3408632)
I have a file with a few thousand lines and I'd like to remove all the lines that have more than 1 asterik (the * character) in it. So if it has 2 or more in a single line, I'd like the line removed (double d command in vi)

Use the following command in vi:

Code:

:g/\*.*\*/d

SentralOrigin 01-14-2009 01:40 PM

Quote:

Originally Posted by nflenz (Post 3408646)
Use the following command in vi:

Code:

:g/\*.*\*/d

Worked flawlessly.


All times are GMT -5. The time now is 09:17 PM.