how to replace a text with a newline


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to replace a text with a newline
# 1  
Old 06-01-2009
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..
# 2  
Old 06-01-2009
this will do

# sed 's/shashi/\
> shashi/g' <file_name>

output
------


shashi how r u ?
shashi , r u their?
shashi....
shashi hello
shashi
# 3  
Old 06-01-2009
Thanks shubhendu..!!


it worked fine...
# 4  
Old 06-02-2009
Hi,

instead of counting 4 numbers from the search, is it possible to print line by line as an user ?


codeis====
user=`echo $record | awk -F, '{print $1}'`


ldapsearch -h ldap uid="$user" uid ou eriMasterDomain eriCountry eriResignDate | \
egrep "^ou=|^eriMasterDomain=|^uid=|^eriCountry= ="|\
print "$user"


nawk 'BEGIN{ORS=" ";DoCR=0}{DoCR=DoCR+1;if((DoCR % 4)==0){print $1 "\n"}else{print $1 " "}}' >> /opt/app/cdm/home/cdm/xshah
eg/ldap/eamcs_output.txt
================

I need to print each user line by line irrespective of his informatiuon...

like----
nawk " if user id is equal then print that line( all info country, domain) otherwise goto next line---------


thanks in advance...
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

replace newline between strings

I'm trying to figure out a way to replace newlines after a unique string is read, all the way until that string occurs again. The input file looks something like this: 02/11/11 22:48:00 This is the first line This is the second line This is the third line 02/11/11 22:49:00 This is the... (8 Replies)
Discussion started by: acruhl
8 Replies

4. Shell Programming and Scripting

Replace newline with comma.

I have output from a file like this: 15,01,11,14:06 235 I would like to change this to: 15,01,11,14:06,235 Removing newline and change to "," I now this can be done with tr cat OUT | tr '\n' ','' My problem is that tr is not implemented in this shell. sed is, show it should be... (7 Replies)
Discussion started by: Jotne
7 Replies

5. Shell Programming and Scripting

replace >< with > newline <

Hi All, I have the command in PERL for performing this, but Can you please suggest me how can i perform this using AWK: My input xml file looks like this: <aaa>hello</aaa><bbb>hai</bbb> I want the output like this ( means need new line after end of each xml tag): <aaa>hello</aaa>... (1 Reply)
Discussion started by: HemaV
1 Replies

6. UNIX for Dummies Questions & Answers

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... (1 Reply)
Discussion started by: aaronpoley
1 Replies

7. 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

8. Shell Programming and Scripting

Replace comma with newline

Hi, for some reason I cant seem to figure this out. I have a file which looks something like this word word word word word,word,word word word word,word,word,word,word word word Basically I want this whole thing to be a list with 1 word on each line like this... word word word... (1 Reply)
Discussion started by: eltinator
1 Replies

9. Shell Programming and Scripting

replace a newline (\n)

dear all: maybe i have a file like : 12 34 56 78 end how do write can i replace newline into NA : make the file inte : 12 NA 34 NA 56 78 END (3 Replies)
Discussion started by: jeter
3 Replies

10. UNIX for Dummies Questions & Answers

How can I replace newline character?

Hi, I am trying to write a script to prepare some text for use as web content. What is happening is that all the newlines in the textfile are ignored, so I want to be able to replace/add a few characters so that for a file containg: This is line 1. This is line two. This is line four.... (1 Reply)
Discussion started by: ghoti
1 Replies
Login or Register to Ask a Question