LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-10-2012, 04:30 AM   #1
gdhienshk
LQ Newbie
 
Registered: Dec 2012
Posts: 2

Rep: Reputation: Disabled
Command needed


HI
I am dhinesh from india i need a help could you pls help me this? my request i have mentioned below

i created one test file name is test inside that i add some numbers ie

1234
5678

from here i want add "test.com" sentence in last line through vi editor after added output should be

1234test.com
5678test.com

how can i add this pls help me
 
Old 12-10-2012, 04:51 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
substitute $ by test.com

Code:
1,$s/$/test.com/
 
Old 12-10-2012, 05:29 AM   #3
gdhienshk
LQ Newbie
 
Registered: Dec 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks a lot it's working

and i need an another help

i have created a test file inside that

1234
5678
3456
7890

i want to change this number as a rows wise through vi command , the output should be

1234,5678,3456,7890

like that

could you pls help me this

I tryed through tr command its working but i dont know how to use through VI help me this

command : cat test | tr \\n \, ( this will work ) i need a help to view through vi
 
Old 12-10-2012, 05:46 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
In vi command mode
Code:
:%s/\n/,/
 
1 members found this post helpful.
Old 12-10-2012, 07:01 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by gdhienshk View Post
Thanks a lot it's working
Pleasure

Quote:
Originally Posted by gdhienshk View Post
I tryed through tr command its working but i dont know how to use through VI help me this
Do you understand (or did you try to understand) what the command that I gave you is doing? If so, I don't think you should have too much of an issue modifying it to your new needs.

Same will apply to the solution of colucix; try to understand what it's doing.
 
1 members found this post helpful.
  


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
Help needed for netstat command manojks Linux - Networking 4 10-27-2011 08:56 AM
dd command help needed. pinga123 Linux - Newbie 1 05-05-2011 10:57 PM
dd command help needed here neocontrol Linux - General 3 10-12-2008 10:18 AM
Help needed for find command ZAMO Linux - General 7 09-23-2008 04:15 AM
linux Command needed cherupop Linux - Newbie 4 07-05-2005 11:33 PM


All times are GMT -5. The time now is 08:27 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