Discussion:
Replace 0d with a space
'Jennings, Kathryn' Kathryn.Jennings@Allstate.com [sed-users]
2016-07-21 12:22:02 UTC
Permalink
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
***@Allstate.com<mailto:***@Allstate.com>


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]
Sven Guckes maillists-yahoo@guckes.net [sed-users]
2016-07-21 16:02:45 UTC
Permalink
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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.
you might be looking for this (taken from sed1line.txt):

# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format.
sed "s/$/`echo -e \\\r`/" # command line under ksh
sed 's/$'"/`echo \\\r`/" # command line under bash
sed "s/$/`echo \\\r`/" # command line under zsh
sed 's/$/\r/' # gsed 3.02.80 or higher

i wonder: why choose sed?
is this just a one-time job?
does it have to be automated?
does it have to be really fast?

for example, converting a single file i'd use the editor vim:

$ vim file
:%j
:x

these commands could be automated/scripted, of course.
but there are many tools out there which can do this.

Sven
--
Sven Guckes sig-sed @guckes.net GNU SED: 4.2.2 [2012-12-22]
SED Download: ftp://ftp.gnu.org/gnu/sed/ SED FAQ: http://go.to/sed-faq
SED One-Liners: http://sed.sf.net/sed1line.txt SEDSED: http://sedsed.sf.net
SED HomePage: http://www.gnu.org/directory/sed.html
'Jennings, Kathryn' Kathryn.Jennings@Allstate.com [sed-users]
2016-07-21 20:29:00 UTC
Permalink
Thank you for your help. I will see if that will do it.


Thanks & Regards,


Kathryn Jennings
Electronic Commerce COE






From: sed-***@yahoogroups.com [mailto:sed-***@yahoogroups.com]
Sent: Thursday, July 21, 2016 11:03 AM
To: sed-***@yahoogroups.com
Subject: Re: Replace 0d with a space
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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.
you might be looking for this (taken from sed1line.txt):


# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format.
sed "s/$/`echo -e \\\r`/<file:///\\\r%60\>" # command line under ksh
sed 's/$'"/`echo \\\r`/<file:///\\\r%60\>" # command line under bash
sed "s/$/`echo \\\r`/<file:///\\\r%60\>" # command line under zsh
sed 's/$/\r/' # gsed 3.02.80 or higher


i wonder: why choose sed?
is this just a one-time job?
does it have to be automated?
does it have to be really fast?


for example, converting a single file i'd use the editor vim:


$ vim file
:%j
:x


these commands could be automated/scripted, of course.
but there are many tools out there which can do this.


Sven


--
Sven Guckes sig-sed @guckes.net GNU SED: 4.2.2 [2012-12-22]
SED Download: ftp://ftp.gnu.org/gnu/sed/<https://urldefense.proofpoint.com/v2/url?u=ftp-3A__ftp.gnu.org_gnu_sed_&d=CwQCAg&c=gtIjdLs6LnStUpy9cTOW9w&r=NAie2iwnZ7jxCSw-kth6IRs1psJ6bmT6MgPbxWPyXlo&m=j9O2dipETxtihLf04YZ9k2kLxk5Xr8w4qY4WG2aXjAM&s=MIrvICZ00srYDK2f2Ou4w6XP6vwBWNOTVZMzUPgcZ7E&e=> SED FAQ: http://go.to/sed-faq<https://urldefense.proofpoint.com/v2/url?u=http-3A__go.to_sed-2Dfaq&d=CwQCAg&c=gtIjdLs6LnStUpy9cTOW9w&r=NAie2iwnZ7jxCSw-kth6IRs1psJ6bmT6MgPbxWPyXlo&m=j9O2dipETxtihLf04YZ9k2kLxk5Xr8w4qY4WG2aXjAM&s=phXGlfT-sLs0swzU92beQDdrSfVwiMZ_TQWj7y5QdTE&e=>
SED One-Liners: http://sed.sf.net/sed1line.txt<https://urldefense.proofpoint.com/v2/url?u=http-3A__sed.sf.net_sed1line.txt&d=CwQCAg&c=gtIjdLs6LnStUpy9cTOW9w&r=NAie2iwnZ7jxCSw-kth6IRs1psJ6bmT6MgPbxWPyXlo&m=j9O2dipETxtihLf04YZ9k2kLxk5Xr8w4qY4WG2aXjAM&s=z0DuzcTR5yOV3UcVTMC0vAUtjG9wtl7siI-dVviNUII&e=> SEDSED: http://sedsed.sf.net<https://urldefense.proofpoint.com/v2/url?u=http-3A__sedsed.sf.net&d=CwQCAg&c=gtIjdLs6LnStUpy9cTOW9w&r=NAie2iwnZ7jxCSw-kth6IRs1psJ6bmT6MgPbxWPyXlo&m=j9O2dipETxtihLf04YZ9k2kLxk5Xr8w4qY4WG2aXjAM&s=8ORFx4iGJAEmurjhDF_IFdRrZ0yK-WViu89-jnl01zM&e=>
SED HomePage: http://www.gnu.org/directory/sed.html<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.gnu.org_directory_sed.html&d=CwQCAg&c=gtIjdLs6LnStUpy9cTOW9w&r=NAie2iwnZ7jxCSw-kth6IRs1psJ6bmT6MgPbxWPyXlo&m=j9O2dipETxtihLf04YZ9k2kLxk5Xr8w4qY4WG2aXjAM&s=qZUp95Y8DKPW1U1lIIE1Vg7sv6OfPAAks0Ko80sk5FY&e=>






[Non-text portions of this message have been removed]
Daniel Goldman dgoldman@ehdp.com [sed-users]
2016-07-21 18:31:19 UTC
Permalink
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/ 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
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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
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]
------------------------------------
------------------------------------
'Jennings, Kathryn' Kathryn.Jennings@Allstate.com [sed-users]
2016-07-21 19:15:51 UTC
Permalink
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: sed-***@yahoogroups.com [mailto:sed-***@yahoogroups.com]
Sent: Thursday, July 21, 2016 1:31 PM
To: sed-***@yahoogroups.com
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
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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
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]
------------------------------------
------------------------------------
[Non-text portions of this message have been removed]
dgoldman@ehdp.com [sed-users]
2016-07-22 19:03:16 UTC
Permalink
Thanks for the extra information. It helps a lot.


I don't think it matters Linux vs Unix, except for the version of tr (or sed) you might be using. The file is a series of bytes. You want to change any 0X0D to a space.


Let us know if the tr command (assuming GNU tr) works:


tr "\015" " " < infile > outfile


The sed command may also work. But the tr command seems simpler and more closely related to what you are trying to do (replace one byte with another).


Daniel


[Non-text portions of this message have been removed]
cs@zip.com.au [sed-users]
2016-07-22 22:39:18 UTC
Permalink
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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.
The dd command will convert EBCDIC.
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
It is delivered to a Linux server (if it makes a difference from Unix).
It should not matter.
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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.
If dd does not do it for you, use tr, avoid sed.

Cheers,
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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
Sent: Thursday, July 21, 2016 1:31 PM
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
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
Post by 'Jennings, Kathryn' ***@Allstate.com [sed-users]
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
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]
------------------------------------
------------------------------------
[Non-text portions of this message have been removed]
------------------------------------
------------------------------------
--
------------------------------------
Yahoo Groups Links
--
dgoldman@ehdp.com [sed-users]
2016-07-26 17:25:42 UTC
Permalink
When you get a chance, let us know what happened, trying the tr command. I'm interested to know if it worked or not. Daniel

[Non-text portions of this message have been removed]
'Jennings, Kathryn' Kathryn.Jennings@Allstate.com [sed-users]
2016-07-27 02:11:16 UTC
Permalink
Daniel,


The tr command worked perfectly!! I'm sorry I didn't have time to try it sooner. Thank you so much for your help!


Thanks & Regards,


Kathryn Jennings
Electronic Commerce COE






From: sed-***@yahoogroups.com [mailto:sed-***@yahoogroups.com]
Sent: Tuesday, July 26, 2016 12:26 PM
To: sed-***@yahoogroups.com
Subject: RE: Replace 0d with a space






When you get a chance, let us know what happened, trying the tr command. I'm interested to know if it worked or not. Daniel


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






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

Loading...