![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Carriage Return at end of file | bd_joy | Shell Programming and Scripting | 14 | 10-20-2006 01:20 PM |
| Removing Carriage Return and or line feed from a file | tbone231 | Shell Programming and Scripting | 1 | 02-18-2005 04:37 PM |
| sed removing carriage return and newline | mored | Shell Programming and Scripting | 2 | 05-06-2004 12:28 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 09:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Issue with Removing Carriage Return (^M) in delimited file
Hi - I tried to remove ^M in a delimited file using "tr -d "\r" and "sed 's/^M//g'", but it does not work quite well. While the ^M is removed, the format of the record is still cut in half, like
a,b, c c,d,e The delimited file is generated using sh script by outputing a SQL query result to tab delimited file. The ^M embedded in the record is captured from user input, I believe. Any insight is appreciated. |
|
||||
|
Re: Can you provide a hex or octal dump of the file?
Hi joeyg,
Thanks for your reply. Unfortunately, this is sensitive data so I can't send out a dump. I did use the od command to pull the data and checked for \r (od -c). I see that there is carriage return (\r)+ new line control (\n) embedded in the record. When I used tr -d "\r\n" , however it remove all line breaks with just "\n". Do you know how I can remove only the string "\r\n" without touching those with only "\n"? Thanks, sirahc |
|
||||
|
Thansk for all your suggestions
Thanks for all your suggestions.
The printf/dos2unix commands did work to some extend but cause format problem to other columns. I eventually used SQL to remove ^M before outputting it to the file. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|