RE: Replace 0d with a space

"'Jennings, Kathryn' [email protected] [sed-users]" <[email protected]> Thu, 21 Jul 2016 19:15:51 +0000
Newsgroups gmane.editors.sed.user
Message-ID <A6FE880E28BA6247ACF8E4ACB27CD04452CC5EEF@A0185-XPO1016-C.ad.allstate.com>
I don’t know how to answer this.  The file is one that is sent to me from a mainframe – as EBCDIC – in a readable format.  It is delivered to a Linux server (if it makes a difference from Unix).  There is a code that is loaded into the data that has a 0D at the end of the data which is causing the file to cut in two.  If I manually delete the 0D and add a space, everything works great.   I figured out how to get the 0D out but can’t figure out how to replace it with a space.    I am using a Kornshell script to do the work.

Let me know if I can give you any more information to help me out.  I will see what I can do with what you’ve sent me.  Thank so much for the response.

Thanks & Regards,

Kathryn Jennings
Electronic Commerce COE



From: [email protected] [mailto:[email protected]]
Sent: Thursday, July 21, 2016 1:31 PM
To: [email protected]
Subject: Re: Replace 0d with a space



Is it a DOS or UNIX file? It might help to know more detail about
exactly what you are trying to accomplish.

https://blog.codinghorror.com/the-great-newline-schism/<https://urldefense.proofpoint.com/v2/url?u=https-3A__blog.codinghorror.com_the-2Dgreat-2Dnewline-2Dschism_&d=CwQCaQ&c=gtIjdLs6LnStUpy9cTOW9w&r=NAie2iwnZ7jxCSw-kth6IRs1psJ6bmT6MgPbxWPyXlo&m=jKarwz4SqjBgMbxqSDglH_NwDgUy8V46Fy9AMLK2ikQ&s=JowX0Srul8v4BRQ48eFk2Ny3M6eerz6MNZHNDBqXjpk&e=> is an article
that gives a pretty decent explanation about 0X0A and 0X0D (octal 15).
It sounds like you already understand about DOS and UNIX newline
conventions?

Anyway, to replace 0X0D with space, using GNU tr or GNU sed, I think the
answer is similar to the other response:

tr "\015" " " (zero)
--- OR ---
sed "s/\o15/ /g" ("little o")

$ echo -e ":\015:" | od -cx # input with 0X0D (octal 15)
0000000 : \r : \n
0d3a 0a3a
0000004

$ echo -e ":\015:" | tr "\015" " " | od -cx
0000000 : : \n
203a 0a3a
0000004

$ echo -e ":\015:" | sed -r "s/\o15/ /g" | od -cx
0000000 : : \n
203a 0a3a
0000004

Daniel

On 7/21/2016 5:22 AM, 'Jennings, Kathryn' [email protected]<mailto:[email protected]>
[sed-users] wrote:
> Hello,
>
>
> I have been trying to remove all 0d characters within a document with a space. I can delete the 0d using tr -d '\n'
> I cannot find anything that will help me replace it. I am thinking that sed is the correct command to use, but am unsure how to code the 0d character.
>
>
>
>
> Thanks & Regards,
>
>
> Kathryn Jennings
> Electronic Commerce COE
>
>
> Allstate Insurance
> 8711 N. Freeport Parkway, MS 4
> Irving, TX 75063
>
>
> Phone 972-915-5384
> Fax 972-915-5483
> [email protected]<mailto:[email protected]<mailto:[email protected]%3cmailto:[email protected]>>
>
>
> The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer.
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
> ------------------------------------
> Posted by: "Jennings, Kathryn" <[email protected]<mailto:[email protected]>>
> ------------------------------------
>





[Non-text portions of this message have been removed]