replace text string with a newline


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers replace text string with a newline
# 1  
Old 04-06-2010
replace text string with a newline

I want to replace a text string with a newline. I have a long text file of random characters. I want to replace all the occurences of "pe" with a newline. How can I do that in Unix? There's a thread from 2004 saying that you can do something like this with sed by actually pressing the return key in the middle of the sed command, but when I try that I get an error immediately after pressing the return key. I will attach a sample test file, testf.
# 2  
Old 04-06-2010
try this...

Code:
sed -i 's/pe/\n/g' <your-file-name>

bye
kamaraj
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replace string including newline

Hi, I am trying to do some transformation on a large file and I am getting some troubles trying remove newlines only when the last character of a line is a symbol (in this case is a pipe "|"). I have tried with sed like this: sed -i 's/|\n/|/g' my_file or sed -i 's/|$/|/gg' my_file... (5 Replies)
Discussion started by: ngb
5 Replies

2. UNIX for Dummies Questions & Answers

Replace variable string with text

Hi All, Hoping someone can help.... I am trying to work out how I can ammend a log file to remove variable strings in order to remove confidential information which I cant pass on. As an example I have used phone numbers. A large log file contains multiple lines containing something like the... (6 Replies)
Discussion started by: mutley2202
6 Replies

3. Shell Programming and Scripting

Replace text/string with new line

Hello All I have had a requirement where I need to move data to a new line based on a text Input :61: 456 B66666 :61: 878 N78777 :61: 534533534 BNNN Output :61: 456 B66666 :61: 878 N78777 :61: 534533534 BNNN So basically as soon as it encounters :61: it should... (3 Replies)
Discussion started by: kamijia83
3 Replies

4. Shell Programming and Scripting

Replace newline in a string

I have a string like below: {\rtf1\fbidis\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}{\f1\fnil MS Sans Serif;}} \viewkind4\uc1\pard\ltrpar\lang2057\f0\fs16 19/11/2010 SOME DESCRIPTION. \par \lang1033\f1\par } I have to replace the newline character with null in the... (8 Replies)
Discussion started by: Pratik4891
8 Replies

5. Shell Programming and Scripting

Search a string in a text and replace

i am having text file below System will display value URGENT and proceed System will display value URGENT and proceed System will display value URGENT and proceed .................................................................. (1 Reply)
Discussion started by: suryanarayana
1 Replies

6. Shell Programming and Scripting

Replace String With Newline

Hi, I'm struggling with a string replacement. I have an XML file which is in the following layout <FUNCTION> <PRODUCTS> <PRODUCT CODE="PRODUCE" ACTION="amend" VALIDATE="no"> <SUPPLIER PRODUCT="PRODUCT" ACTION="amend" CODE="SUPPLIER"> <STOCK_QUANTITY DATA="21"/> ... (15 Replies)
Discussion started by: Ste_Moore01
15 Replies

7. Shell Programming and Scripting

Help with sed matching <tag1> newline spaces <tag2> and replace the value in the same string format

Hi, I'm very new to shell scripting and have searched google and this forum for quite some time now. I have the following in my xml file: <recipients> <member>value1</member> </recipients> I need to find a string <recipients> that follows with a new-line and bunch of spaces and... (5 Replies)
Discussion started by: mgharios
5 Replies

8. Shell Programming and Scripting

Replace a string with newline

Hi all I have the problem to substitute a string with newline in Perl. Can anybody help me? And also how to replace a string with opening bracket (e.g. (START ) with a whitespace/null character? Thanks in advance. (1 Reply)
Discussion started by: my_Perl
1 Replies

9. UNIX for Dummies Questions & Answers

how to replace a text with a newline

Hi. How to replace a text in a file with starting from a newline example==== shashi how r u ? shashi , r u their? shashi.... shashi hello shashi output will be shashi how r u ? shashi , r u their? shashi.... shashi hello shashi ========= thanks in advance.. (3 Replies)
Discussion started by: hegdeshashi
3 Replies

10. UNIX for Dummies Questions & Answers

replace string with a newline string

Hi, I wanted to replace these lines in vi editor: input-- uid=ESVPEME | eriMasterDomain=EAMCS | eriCountry=El | ou=ESV uid=EPYCAR | eriMasterDomain=EAMCS | eriCountry=Argentina | ou=CEA uid=ERCFGA | eriMasterDomain=EAMCS | eriCountry=Costa | ou=ERC uid=EDGLUCU | eriMasterDomain=EAMCS... (5 Replies)
Discussion started by: hegdeshashi
5 Replies
Login or Register to Ask a Question