The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how can i replace "(", "\" "+" in a file mail2sant Shell Programming and Scripting 3 04-22-2008 08:10 PM
Sed , Replace a "variable text" inside of a statement jackn7 Shell Programming and Scripting 4 03-04-2008 11:40 AM
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 11:00 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 09:52 PM
deleting newline characters but not the "true" \n character caddyjoe77 Shell Programming and Scripting 1 08-15-2007 07:21 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-06-2001
Registered User
 

Join Date: Mar 2001
Location: CA
Posts: 5
Stumble this Post!
How to replace newline "\n"

How do I replace the newline character in "vi" editor.

I want to replace the string " \n" (ie, Blank followed by NewLine) with " " . How do I do this?

I want to try this from vi editor and then using "sed".


Thanks,
Forum Sponsor
  #2 (permalink)  
Old 06-06-2001
Users Awaiting Email Confirmation
 

Join Date: Jun 2001
Location: ISRAEL
Posts: 2
Stumble this Post!
If you want to marge rows ( for exp. row 1 to 20 ) do:
:1,20 j
  #3 (permalink)  
Old 06-07-2001
mib mib is offline
Registered User
 

Join Date: Jan 2001
Location: Calicut
Posts: 228
Stumble this Post!

tr "\n" " " < filename


  #4 (permalink)  
Old 06-07-2001
Registered User
 

Join Date: Mar 2001
Location: CA
Posts: 5
Stumble this Post!
But, I want to replace the newline character only if it is followed by a blank space.

ie, I wan to replace "blankspace\n" with "blankspace" and dont want to replace (say, ";\n")

Thank u verymuch for your response
  #5 (permalink)  
Old 06-09-2001
Registered User
 

Join Date: Nov 2000
Location: India
Posts: 83
Stumble this Post!
NewLine

What i interpreted from your question is that you have a file in which the text is somewhat as shown

\n
sdsdjfsjnfj \n asdmkasmdkamdk \n
sdmfksdmfksd \n
\n
masdkak \n
\n

and now you want to replace the " \n" with ""
so you can try the search and replace command i.e
:%s/ \\n//g
I tried this on solaris and it worked fine.

  #6 (permalink)  
Old 06-09-2001
Registered User
 

Join Date: Mar 2001
Location: CA
Posts: 5
Stumble this Post!
It didn't work on Linux.

Note where "\n" is new line. It seems u are taking "\n" as a string of "\" and character "n".

Thanks,
Google The UNIX and Linux Forums
Closed Thread

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0