replacing \n by \r\n | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

replacing \n by \r\n

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 12-07-2002
crashnburn crashnburn is offline
Registered User
 
Join Date: Feb 2002
Last Activity: 1 December 2003, 8:02 AM EST
Location: Portugal
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
replacing \n by \r\n

hi there,

sometimes i want to send some of my friends some text files (they use that OS u know the name), so i'd like to filter all line feeds and replace them by a carriage return + line feed. does anyone know how i can do that?

thx
Sponsored Links
    #2  
Old 12-07-2002
WIntellect's Avatar
WIntellect WIntellect is offline
Registered User
 
Join Date: Sep 2002
Last Activity: 29 March 2005, 11:13 AM EST
Location: United Kingdom
Posts: 170
Thanks: 0
Thanked 0 Times in 0 Posts
Someone showed me this once (in this forum I believe) - so all credit to that person, but I can't remember who (sorry if you know it was you!); works a treat:

Code:
perl -i -pne "s/\n/\r\n/g" filename

This converts the file directly, so you wont get a different output file. You can then revesre the \n and \r\n to change a Windows file to Unix!!!

Happy converting
Sponsored Links
    #3  
Old 12-09-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
 
Join Date: Jul 2001
Last Activity: 16 June 2011, 4:50 PM EDT
Location: Portland, OR, USA
Posts: 1,626
Thanks: 2
Thanked 15 Times in 13 Posts
See if you have the unix2dos utility installed. It has a counterpart called, you guessed it, dos2unix...

Some systems call it dostounix or dos2ux...

Good luck.
    #4  
Old 11-24-2003
dianar dianar is offline
Registered User
 
Join Date: Nov 2003
Last Activity: 25 November 2003, 11:39 AM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Oh... THIS looks like exactly what I NEED! Sorry about the other post!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help with SED for replacing an IP sags007_99 Shell Programming and Scripting 1 01-15-2012 02:36 AM
SED: replacing unknown7 Shell Programming and Scripting 3 02-15-2011 11:02 AM
replacing / to - rudoraj Shell Programming and Scripting 2 12-08-2008 03:03 PM
Replacing in SED superprogrammer Shell Programming and Scripting 8 07-11-2006 02:33 AM
replacing with `pwd` oldtrash Shell Programming and Scripting 6 04-09-2004 06:24 PM



All times are GMT -4. The time now is 09:08 AM.