LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2008, 07:48 AM   #1
ajeetraina
Member
 
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292

Rep: Reputation: 30
Playing with Vi editor??


Hello Guys,

I have a sample entry for 2300 users like the one below.All I want to delete the line starting with mailROutingAddress,mail,sn etc completely.
Can anyone help me how can I delete the entire line starting with these characters in one shot through Ex-mode?



dn: uid=sharmam,ou=People,dc=im,dc=logica,dc=com
uid: sharmam
cn: Manish Sharma
givenName: Manish
sn: Sharma
mail: sharmam@logica.com
mailRoutingAddress: sharmam@mail.logica.com
mailHost: mail.logica.com
objectClass: inetLocalMailRecipient
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson


Pls Help

Last edited by ajeetraina; 02-14-2008 at 07:50 AM.
 
Old 02-14-2008, 08:23 AM   #2
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
Hi, try

Code:
:/^mailRoutingAddress:/ d
 
Old 02-14-2008, 02:05 PM   #3
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
For future, if you are interested. there's a website with tutorials and cheat sheets for Vi..

http://www.viemu.com/a_vi_vim_graphi..._tutorial.html
 
Old 02-15-2008, 12:12 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Alternately

:%s/^mailRoutingAddress:.*//

for all lines (%) substitute (s) match line starts with (^) string (mailRoutingAddress followed by any char (.) any num (zero or more) of times (*) replace with nothing (//)

for anyone new to vi/vim
 
Old 02-15-2008, 12:46 AM   #5
ajeetraina
Member
 
Registered: Jun 2007
Location: India
Distribution: Ubuntu,Red Hat, Fedora
Posts: 292

Original Poster
Rep: Reputation: 30
The Ex-command :%s/^mailRoutingAddress:.*// seems to work but is leaving a line...like this :

dn: uid=apache,ou=People,dc=im,dc=logica,dc=com
uid: apache
cn: Apache
sn: Apache
mail: apache@logica.com
mailRoutingAddress: apache@mail.logica.com
mailHost: mail.logica.com
objectClass: inetLocalMailRecipient
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
objectClass: kerberosSecurityObject
objectClass: shadowAccount
userPassword: {crypt}!!
shadowLastChange: 13801
shadowMax: 99999
shadowWarning: 7

loginShell: /sbin/nologin
uidNumber: 48
gidNumber: 48
homeDirectory: /var/www
gecos: Apache

How to delete the blank line
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vi editor IwantLINUX Linux - Newbie 8 06-28-2005 10:28 AM
Totem playing off of network, Xine playing local iammike Ubuntu 0 04-30-2005 11:43 AM
best editor Kaninchen Linux - Software 14 07-27-2004 06:52 PM
what about your editor ? black General 16 12-03-2003 08:16 PM
vi editor ?? johnyy Linux - Software 3 07-13-2003 01:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration