LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-14-2009, 01:29 PM   #1
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Rep: Reputation: 30
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)
 
Old 01-14-2009, 01:35 PM   #2
nflenz
Member
 
Registered: Feb 2006
Distribution: CRUX 2.4
Posts: 96

Rep: Reputation: 18
Quote:
Originally Posted by SentralOrigin View Post
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
 
Old 01-14-2009, 01:40 PM   #3
SentralOrigin
Member
 
Registered: Jul 2005
Distribution: Gentoo, Ubuntu
Posts: 318

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by nflenz View Post
Use the following command in vi:

Code:
:g/\*.*\*/d
Worked flawlessly.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove last character from file/string linuxchump Programming 34 06-08-2009 04:01 AM
How do I remove everything after a certain character in text files? SentralOrigin Linux - General 3 01-14-2009 02:15 PM
Remove rightmost character from bash gn00kie Programming 9 01-29-2008 12:08 AM
remove the 'd' character from the end of string powah Programming 6 11-08-2007 07:00 AM
vi command to find and delete all lines beginning with a character geomatt Linux - Software 8 12-20-2004 03:30 AM


All times are GMT -5. The time now is 06:04 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration