LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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, 08: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 08:50 AM.
 
Old 02-14-2008, 09: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, 03:05 PM   #3
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Willoughby, Ohio
Distribution: linuxdebian
Posts: 7,232
Blog Entries: 5

Rep: Reputation: 190Reputation: 190
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, 01:12 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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, 01: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


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



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


All times are GMT -5. The time now is 10:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration