Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-05-2004
Registered User
 

Join Date: May 2004
Posts: 1
sed removing carriage return and newline

Hi,

I'm not very familiar with unix shell. I want to replace the combination of two carriage returns and one newline with one carriage return and one newline. I think the best way to do this is to use sed. I tried something like this:

sed -e "s#\[/r][/r][/n]#\[/r][/n]#g" file.txt

but it doesn't work.
Thanx in advance.

Greetings

Gina
Sponsored Links
  #2 (permalink)  
Old 05-06-2004
Registered User
 

Join Date: Sep 2003
Posts: 25
Hi Gina,

Try something along these lines

sed 's!\\r\\r\\n!\\r\\n!g' file.txt
Hope this helps.

Matt.

Last edited by butterfm; 05-06-2004 at 11:51 AM..
  #3 (permalink)  
Old 05-06-2004
Ygor's Avatar
Ygor Ygor is online now Forum Staff  
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,431
sed uses $ as the end of line marker (i.e newline), so use something like...

Code:
$ CR=`printf "\r"`
$ printf "\r\r\n" | sed "s/$CR$CR$/$CR/g" | od -hc
0000000    0d0a
         \r  \n
0000002

Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Issue with Removing Carriage Return (^M) in delimited file sirahc UNIX for Advanced & Expert Users 7 03-25-2008 05:08 AM
Substituting carriage return followed by newline character - HELP djkane Shell Programming and Scripting 14 02-28-2006 09:58 PM
Substituting carriage return follwed by newline character - HELP! djkane UNIX for Dummies Questions & Answers 1 02-27-2006 09:11 PM
Removing Carriage return to create one record r1500 Shell Programming and Scripting 3 02-06-2004 03:45 PM
Removing carriage return characters from file b1saini UNIX for Dummies Questions & Answers 3 09-10-2003 10:41 AM



All times are GMT -4. The time now is 02:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0