LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 05-15-2008, 04:42 AM   #1
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Rep: Reputation: 29
how to add a charachter on every line in vi editor


Hi,

I have a large list for blocking porno sites. I need to add a dot on every line within vi editor can any budy tell me that what will be the all in one command to add a dot on every line.

thanks in advance
 
Old 05-15-2008, 05:08 AM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
You'd be faster in sed, e.g.

sed -i 's/$/./g' filename

will add a dot at the end of each line in 'filename'

Dave
 
Old 05-15-2008, 05:46 AM   #3
indeliblestamp
Member
 
Registered: Feb 2006
Distribution: Fedora
Posts: 341
Blog Entries: 3

Rep: Reputation: 38
%s/.*/&.
i.e on every line of the file/select the whole line/replace with the whole line followed by a dot.
 
Old 05-15-2008, 11:57 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
vi

:%s/$/./
 
Old 05-16-2008, 12:06 AM   #5
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL 4
Posts: 360

Original Poster
Rep: Reputation: 29
it should be the beggning of line not the end of line. a dot on the beggining of line. for example


.xyz.com
.abc.com
.najo.com
 
Old 05-19-2008, 12:28 AM   #6
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Why didn't you say

vim

:%s/^/./
 
  


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
How to remove last charachter (last bit) from file? igorblackbelt Linux - Newbie 3 05-02-2007 12:29 PM
commenting more than one line in VI editor newbloggy Linux - Software 1 04-18-2006 07:09 AM
How do I add icons to menu editor,MDK9.2 akihandyman Mandriva 3 02-29-2004 03:59 PM
VI text editor in command line InSane103 Linux - Software 4 07-09-2003 09:04 PM
vi as Command Line Editor taz75 Linux - Newbie 8 01-04-2002 01:30 PM


All times are GMT -5. The time now is 10:53 AM.

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