Add new lines


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Add new lines
# 1  
Old 05-02-2010
Add new lines

I have a file that contains email addresses separated by comma in one line.

I would like to replace the comma with a new line

for example all these email addresses are in one line.

Test1@tester.com, Test2@tester.com, Test3@tester.com, Test4@tester.com , Test5@tester.com

I would like to know a uniq command in Vi editor to replace the , space with a new line so that my output looks like

Test1@tester.com
Test2@tester.com
Test3@tester.com
Test4@tester.com
Test5@tester.com

Any helps is really appreciated.
# 2  
Old 05-02-2010
Debian

Code:
:%s/,/CtrlVCtrlM/g

will replace commas with new lines
Code:
:%s/ //g

will remove all whitespaces
# 3  
Old 05-02-2010
The CtrlVCtrlM thing is pretty neat.

You could combine the two statements:
Code:
:%s/, */CtrlVCtrlM/g

# 4  
Old 05-02-2010
At first sight it seems to work, and it does, but note the remaining trailing whitespace of the fourth line Smilie
# 5  
Old 05-02-2010
thanks folks it worked (ControlVControlM) did the trick
# 6  
Old 05-05-2010
MySQL

This cant run for me maybe require vim mode Smilie

After vi operation
Code:
:%s/, */CtrlVCtrlM/g

Code:
# cat mailler
Test1@tester.comCtrlVCtrlMTest2@tester.comCtrlVCtrlMTest3@tester.comCtrlVCtrlMTest4@tester.comCtrlVCtrlMTest5@tester.com



I use code like this

Code:
:%s/, /\r/g

After vi operation

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add string into certain lines - sed

Hello all, I have surely an easy question - but at the moment I do not see the solution. All what I want is to add the string "/9201" within a file when a line starts with ":47A:". This is how a file look like: Information Tool :12:Delimiter :3:Space :47A:0329 :3:Space After the... (2 Replies)
Discussion started by: API
2 Replies

2. Shell Programming and Scripting

Extract some lines from one file and add those lines to current file

hi, i have two files. file1.sh echo "unix" echo "linux" file2.sh echo "unix linux forums" now the output i need is $./file2.sh unix linux forums (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

3. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

4. UNIX for Dummies Questions & Answers

how to add new lines using sort

Hello, I'm trying to sort a file which has many lines with the sort command. I'd like to send the sorted content in the same file. But when I do that, I've the content which is sorted, but all is on one line... I view the content in Notepad++ Could somebody help me to keep the original... (5 Replies)
Discussion started by: tevious
5 Replies

5. UNIX for Dummies Questions & Answers

how to add duplicate lines

Hi, I have a file that looks like this: a_X data a_Y data b data c data d_X data d_Y data I **want** to duplicate the lines without the _X and _Ys. In other words, I want it to look like this a_X data a_Y data b data b data c data c data d_X data d_Y data (13 Replies)
Discussion started by: mikey11415
13 Replies

6. Shell Programming and Scripting

Add blank lines

Hi! I am trying to add blank lines at the end of a text file just before the last line. (This is a part of a script) For example this is my text file... lines with dashes are included The problem is that i dont know before hand the number of blank lines to be added. The number of blank... (4 Replies)
Discussion started by: jepeto
4 Replies

7. Shell Programming and Scripting

How can I add 4 lines together and then read the next 4 lines?

Hi, I have grep:ed on a file with which gives the below output. Total = 43 Total = 21 Total = 23 Total = 2 Total = 3 Total = 1 Total = 0 I would like to add the first 4th lines to a total amount, and do so on for the rest of the lines. I was thinking in terms of using while read.... (32 Replies)
Discussion started by: mr_andrew
32 Replies

8. UNIX for Advanced & Expert Users

Add new lines with a space in beginning

Hi file1.txt contains GigabitEthernet1/1 GigabitEthernet1/2 GigabitEthernet2/2 GigabitEthernet2/4 GigabitEthernet2/14 GigabitEthernet2/16 can anyone show me how to modify it as below. there is a space at the beginning of the next two lines . ie 'no shut' and 'switch..' !... (8 Replies)
Discussion started by: Aejaz
8 Replies

9. Shell Programming and Scripting

Sed Add New Lines

Hello, I have a file that has data like this: one two three four five six seven eight nine ten Is there a quick way using sed of nawk to put each word on it's own line? Thanks. (2 Replies)
Discussion started by: bestbuyernc
2 Replies

10. Shell Programming and Scripting

Add lines into file

Hi, i have a file like: 00:00 8 00:01 2 00:04 5 00:07 10 . . . and i need to add the other minutes with value 0 and have a file like: 00:00 8 00:01 2 00:02 0 00:03 0 00:04 5 00:05 0 00:06 ... (13 Replies)
Discussion started by: Lestat
13 Replies
Login or Register to Ask a Question