The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Remove Similar Lines from a File Nysif Steve Shell Programming and Scripting 4 03-13-2009 03:49 AM
How to remove the lines from file using perl dipakg Shell Programming and Scripting 5 06-03-2008 07:49 AM
remove blank lines in *.srt file :) hungbp UNIX for Dummies Questions & Answers 10 02-16-2008 08:40 AM
remove lines from file bluemoon1 Shell Programming and Scripting 9 11-09-2007 01:40 AM
remove extra lines in the file CamTu Shell Programming and Scripting 8 03-29-2005 01:13 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-03-2007
kjbaumann kjbaumann is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 49
vi to remove lines in file

All,

I have a text file with several entries like below:

personname
personname.domain.com

I know there is a way to use vi to remove only the personname.domain.com line. Can someone help? I believe that it involves /s/g/ something...I just can't remember the exact syntax.

Thanks
  #2 (permalink)  
Old 10-03-2007
kjbaumann kjbaumann is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 49
I got it:

:g/outdated/d

This command tells vi to do a global search for "outdated" and to delete any line containing that text.

:g/out dated/d

This command tells vi to do a global search for "out dated" and to delete any line containing that text--including the space.
  #3 (permalink)  
Old 03-13-2009
uniesh uniesh is offline
Banned
  
 

Join Date: Mar 2009
Posts: 16
vi

go to editor mode of vi and type :'g/outdated/d'. this wil delete all lines with the worh outdated.

You can also use :'1,10/outdated/d' to delete lines from 1 to 10 with the word outdated.
Closed Thread

Bookmarks

Tags
vim

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0