Substituting carriage return followed by newline character - HELP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substituting carriage return followed by newline character - HELP
# 1  
Old 02-27-2006
Substituting carriage return followed by newline character - HELP

--------------------------------------------------------------------------------

Hi All

I have a field being returned from the DB that when opened in Vi shows a ^M before the rest of the field is displayed on the next line.

I need it so that the only newline character is the end of the line since I need to transform my file into an Excel report.

Thus my idea is to substitute the combination of ^M and newline character with nothing.

I've been tryin the following

sed s/^M\n//g myFile.out

but this isn't working. Can anyone help me?

Thanks,

Darren
# 2  
Old 02-27-2006
Your duplicated thread - Substituting carriage return follwed by newline character - HELP! . Please dont duplicate. Its against the rules.

Try dos2unix myFile.out on your file to get rid of the ^M characters.
# 3  
Old 02-27-2006
Sorry mate. First time using the forums and i wasn't sure how to move the thread as I think I posted it in the wrong place to begin with.

I will try your suggestion.
# 4  
Old 02-27-2006
dos2unix is not a recognised command. I already remove the ^M using the sed command but i need to remove it <b> in combination with </b> the newline character.

Any other ideas?
# 5  
Old 02-27-2006
try using dos2ux command
I just found out that on some systems it may be dos2unix

Gaurav
# 6  
Old 02-27-2006
dos2ux does not work either Smilie
# 7  
Old 02-27-2006
Post the results of uname -a

You also mentioned that you have removed ^M using sed. What is it that you are looking for now ? Remove <b>^M</b> ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove carriage return

I need to remove the carriage return comes inbetween the record. Need to have CR only at the end. I used the below command. tr -d '\n' < filewithcarriagereturns > filewithoutcarriagereturns But its removing all the CR and giving one line output. Input File: 12345 abcdegh... (11 Replies)
Discussion started by: srvn_saru
11 Replies

2. Shell Programming and Scripting

Substitute \n with carriage return

Hello all, I've a flat file in the following format: AB\001\CDED\001\ABC\001\nEG\001\HIJF\001\EFG\001\nHI\003\HIUL\003\HIJ\003 And I want to substitute \n with the carriage return. Any help is appreciated! Regards, - Seth (8 Replies)
Discussion started by: sethmj
8 Replies

3. Shell Programming and Scripting

2 carriage return within a record

Hi all, need your help in replacing carriage return in a record. Input: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10 1|aa|bb|cc|dd|eee eee|ff|ggggg|hh hhh|iii 2|zz|yy|xx|ww|vv|uu|tt|ss|rr Output: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10... (12 Replies)
Discussion started by: agathaeleanor
12 Replies

4. Shell Programming and Scripting

Help substituting text in a file having a single line but no newline char

Hello, Need help substituting a particular word in a file having a single line but no newline character at the end. I was trying to use sed but it doesn't work probably because there is no newline char at the end of the line. $ cat hlq_detail /outputs/alvan23/PDFs/bills $ cat... (5 Replies)
Discussion started by: Shan_u2005
5 Replies

5. UNIX for Dummies Questions & Answers

carriage return and linefeed

hi can anyone please tell me the difference between carriage return, linefeed and newline ? (2 Replies)
Discussion started by: streetfi8er
2 Replies

6. Shell Programming and Scripting

carriage return or funky character stuck in my variables - help :)

My variables contain carriage returns... or something. Here is the line in my xml file of interest: <tmp>72</tmp> And here is the line that extracts the 72 from it: REAL=`grep '<tmp>' test.xml | sed -e 's/^ *<tmp>//' -e 's/<\/tmp>//' -re 's/(N|n|A|a|\/)/U/g'`If echo the variable it... (5 Replies)
Discussion started by: audiophile
5 Replies

7. UNIX for Dummies Questions & Answers

Substituting carriage return follwed by newline character - HELP!

Hi All I have a field being returned from the DB that when opened in Vi shows a ^M before the rest of the field is displayed on the next line. I need it so that the only newline character is the end of the line since I need to transform my file into an Excel report. Thus my idea is to... (1 Reply)
Discussion started by: djkane
1 Replies

8. Shell Programming and Scripting

Dont want carriage return

I have observed with print & echo, they produce carriage return <CR> or newline, after they display string next to them. Is there anyway to avoide these <CR> after the intended string is displayed? (3 Replies)
Discussion started by: videsh77
3 Replies

9. Shell Programming and Scripting

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#\#\#g" file.txt but it doesn't work. Thanx... (2 Replies)
Discussion started by: mored
2 Replies

10. Shell Programming and Scripting

Capture carriage return.

I try to test the carriage return in a variable. $ LENGTH=`expr $VARIABLE : ".*"` will return the length of the variable. But this doesn't work if $VARIABLE has zero length. Any help will be well appreciated. Thanks in advance. Giovanni (4 Replies)
Discussion started by: gio123bg
4 Replies
Login or Register to Ask a Question