Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Your program is sick! Shoot it and put it out of its memory.


devel / comp.unix.shell / Convert CR LF to CR

SubjectAuthor
* Convert CR LF to CRHarry
+* Re: Convert CR LF to CREd Morton
|`* Re: Convert CR LF to CRHarry
| `* Re: Convert CR LF to CREd Morton
|  `* Re: Convert CR LF to CRHarry
|   `* Re: Convert CR LF to CREd Morton
|    `* Re: Convert CR LF to CRHarry
|     +- Re: Convert CR LF to CRHarry
|     `* Re: Convert CR LF to CRDavid W. Hodgins
|      `* Re: Convert CR LF to CRHarry
|       `* Re: Convert CR LF to CRDavid W. Hodgins
|        `- Re: Convert CR LF to CRHarry
+* Re: Convert CR LF to CRKenny McCormack
|`- Re: Convert CR LF to CRHarry
+- Re: Convert CR LF to CRHarry
+* Re: Convert CR LF to CRKeith Thompson
|`- Re: Convert CR LF to CRHarry
+* Re: Convert CR LF to CRKaz Kylheku
|`* Re: Convert CR LF to CRHarry
| +- Re: Convert CR LF to CRKenny McCormack
| +- Re: Convert CR LF to CRKaz Kylheku
| `* Re: Convert CR LF to CRSpiros Bousbouras
|  +* Re: Convert CR LF to CRJanis Papanagnou
|  |`* Re: Convert CR LF to CRKeith Thompson
|  | `* Re: Convert CR LF to CRJanis Papanagnou
|  |  `* Re: Convert CR LF to CRKeith Thompson
|  |   +* Re: Convert CR LF to CRJanis Papanagnou
|  |   |+* Reading a file all in one go in GAWK (Was: Convert CR LF to CR)Kenny McCormack
|  |   ||+- Re: Reading a file all in one go in GAWK (Was: Convert CR LF to CR)Janis Papanagnou
|  |   ||`- Re: Reading a file all in one go in GAWKBen Bacarisse
|  |   |`* Re: Convert CR LF to CREd Morton
|  |   | +- Re: Convert CR LF to CRKenny McCormack
|  |   | `* Re: Convert CR LF to CRJanis Papanagnou
|  |   |  +* Re: Convert CR LF to CREd Morton
|  |   |  |+- Re: Convert CR LF to CRKenny McCormack
|  |   |  |`* Re: Convert CR LF to CRJanis Papanagnou
|  |   |  | +* Re: Convert CR LF to CREd Morton
|  |   |  | |`* Re: Convert CR LF to CRJanis Papanagnou
|  |   |  | | `* Re: Convert CR LF to CREd Morton
|  |   |  | |  `* [OT] GNU Awk's regexp RS behavior (was Re: Convert CR LF to CR)Janis Papanagnou
|  |   |  | |   `* Re: [OT] GNU Awk's regexp RS behavior (was Re: Convert CR LF to CR)Janis Papanagnou
|  |   |  | |    `- Re: [OT] GNU Awk's regexp RS behavior (was Re: Convert CR LF to CR)Ed Morton
|  |   |  | `* Re: Convert CR LF to CRWilliam Unruh
|  |   |  |  +- Re: Convert CR LF to CRJanis Papanagnou
|  |   |  |  `* Re: Convert CR LF to CREd Morton
|  |   |  |   `- Re: Convert CR LF to CREd Morton
|  |   |  +* Re: Convert CR LF to CREd Morton
|  |   |  |`- Re: Convert CR LF to CRJanis Papanagnou
|  |   |  `- Re: Convert CR LF to CRSpiros Bousbouras
|  |   +* GNU Awk bulk load of file (manual references) (was Re: Convert CR LFJanis Papanagnou
|  |   |`* Re: GNU Awk bulk load of file (manual references) (was Re: Convert CR LFKenny McCormack
|  |   | `- Re: GNU Awk bulk load of file (manual references) (was Re: Convert CRJanis Papanagnou
|  |   `- Re: Convert CR LF to CRBen Bacarisse
|  `- Re: Convert CR LF to CRHarry
`* Re: Convert CR LF to CRKeith Thompson
 `- Re: Convert CR LF to CRHarry

Pages:123
Convert CR LF to CR

<3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4053&group=comp.unix.shell#4053

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:5c8c:: with SMTP id r12mr34272889qta.265.1625847547197;
Fri, 09 Jul 2021 09:19:07 -0700 (PDT)
X-Received: by 2002:a0c:ba05:: with SMTP id w5mr37531249qvf.60.1625847547001;
Fri, 09 Jul 2021 09:19:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 09:19:06 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Subject: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 16:19:07 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 16:19 UTC

I have a text file that need to covert CR LF to CR.

Sample input
--
LF
LF
Line 1 CR LF
Line 2 CR LF
LF
LF
LF
Line 3 CR LF
....
--

Expected output
--
LF
LF
Line 1 CR
Line 2 CR
LF
LF
LF
Line 3 CR
....
--

I have tried the following, but the output file has no change.

sed -e 's#\r\n#\r#g' < infile > outfile
sed -e 's#\x0D\x0A#\x0D#g' < infile > outfile

Any suggestion?

TIA

Re: Convert CR LF to CR

<sc9tit$ohj$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4054&group=comp.unix.shell#4054

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 11:30:09 -0500
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <sc9tit$ohj$1@dont-email.me>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Jul 2021 16:30:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9beb3e3dd0b463cc6cab0062b0d90ac4";
logging-data="25139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wu28lbyl/MSPB5r9/mDQO"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:el+YSc7+7YD/v3PfkvLao4If/50=
In-Reply-To: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210709-0, 7/8/2021), Outbound message
 by: Ed Morton - Fri, 9 Jul 2021 16:30 UTC

On 7/9/2021 11:19 AM, Harry wrote:
> I have a text file that need to covert CR LF to CR.
>
> Sample input
> --
> LF
> LF
> Line 1 CR LF
> Line 2 CR LF
> LF
> LF
> LF
> Line 3 CR LF
> ...
> --
>
> Expected output
> --
> LF
> LF
> Line 1 CR
> Line 2 CR
> LF
> LF
> LF
> Line 3 CR
> ...
> --
>
> I have tried the following, but the output file has no change.
>
> sed -e 's#\r\n#\r#g' < infile > outfile
> sed -e 's#\x0D\x0A#\x0D#g' < infile > outfile
>
> Any suggestion?
>
> TIA
>

If that first sed command didn't do it then your input file isn't as
expected, assuming you don't REALLY have a blank char between each CR
and LF as your sample input shows (i.e. you have CRLF, not CR LF). Run
`cat -Ev` on your input file and copy/paste the output here.

Ed.

Re: Convert CR LF to CR

<sc9ucj$39g8u$1@news.xmission.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4055&group=comp.unix.shell#4055

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 16:44:03 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sc9ucj$39g8u$1@news.xmission.com>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Injection-Date: Fri, 9 Jul 2021 16:44:03 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3457310"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 9 Jul 2021 16:44 UTC

In article <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>,
Harry <harryooopotter@hotmail.com> wrote:
>I have a text file that need to covert CR LF to CR.
>
>Sample input
>--
>LF
>LF
>Line 1 CR LF
>Line 2 CR LF
>LF
>LF
>LF
>Line 3 CR LF
>...
>--
>
>Expected output
>--
>LF
>LF
>Line 1 CR
>Line 2 CR
>LF
>LF
>LF
>Line 3 CR
>...
>--

--- Cut Here ---
#!/usr/bin/awk
gsub(/CR LF/,"CR") + 1
--- Cut Here ---

--

Prayer has no place in the public schools, just like facts
have no place in organized religion.
-- Superintendent Chalmers

Re: Convert CR LF to CR

<5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4056&group=comp.unix.shell#4056

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:6203:: with SMTP id w3mr26778265qkb.81.1625849944083;
Fri, 09 Jul 2021 09:59:04 -0700 (PDT)
X-Received: by 2002:ac8:7c98:: with SMTP id y24mr11082301qtv.268.1625849943951;
Fri, 09 Jul 2021 09:59:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 09:59:03 -0700 (PDT)
In-Reply-To: <sc9tit$ohj$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com> <sc9tit$ohj$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 16:59:04 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 16:59 UTC

On Friday, July 9, 2021 at 9:30:25 AM UTC-7, Ed Morton wrote:
> On 7/9/2021 11:19 AM, Harry wrote:
> > I have a text file that need to covert CR LF to CR.
> >
> > Sample input
> > --
> > LF
> > LF
> > Line 1 CR LF
> > Line 2 CR LF
> > LF
> > LF
> > LF
> > Line 3 CR LF
> > ...
> > --
> >
> > Expected output
> > --
> > LF
> > LF
> > Line 1 CR
> > Line 2 CR
> > LF
> > LF
> > LF
> > Line 3 CR
> > ...
> > --
> >
> > I have tried the following, but the output file has no change.
> >
> > sed -e 's#\r\n#\r#g' < infile > outfile
> > sed -e 's#\x0D\x0A#\x0D#g' < infile > outfile
> >
> > Any suggestion?
> >
> > TIA
> >
> If that first sed command didn't do it then your input file isn't as
> expected, assuming you don't REALLY have a blank char between each CR
> and LF as your sample input shows (i.e. you have CRLF, not CR LF). Run
> `cat -Ev` on your input file and copy/paste the output here.
>
> Ed.

Here you go ...

$ sed -e 's#\r\n#\r#g' < infile > outfile

$ cat -Ev infile
$ $
MSH|blablabla^M$
OBX|blablabla^M$
$ $
$ MSH|blablabla^M$
OBX|blablabla^M$
$ $
$

$ cat -Ev outfile
$ $
MSH|blablabla^M$
OBX|blablabla^M$
$ $
$ MSH|blablabla^M$
OBX|blablabla^M$
$ $
$

Re: Convert CR LF to CR

<e6fc908a-a7dc-4b5d-bd3a-a0fa6403c1dbn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4057&group=comp.unix.shell#4057

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:4004:: with SMTP id h4mr778913qko.370.1625850351796;
Fri, 09 Jul 2021 10:05:51 -0700 (PDT)
X-Received: by 2002:ac8:7a61:: with SMTP id w1mr15549938qtt.176.1625850351681;
Fri, 09 Jul 2021 10:05:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 10:05:51 -0700 (PDT)
In-Reply-To: <sc9ucj$39g8u$1@news.xmission.com>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com> <sc9ucj$39g8u$1@news.xmission.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e6fc908a-a7dc-4b5d-bd3a-a0fa6403c1dbn@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 17:05:51 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 17:05 UTC

On Friday, July 9, 2021 at 9:44:08 AM UTC-7, Kenny McCormack wrote:

> --- Cut Here ---
> #!/usr/bin/awk
> gsub(/CR LF/,"CR") + 1
> --- Cut Here ---

$ sh xx.awk < infile > outfile
xx.awk: line 2: syntax error near unexpected token `/CR'
xx.awk: line 2: `gsub(/CR LF/,"CR") + 1'

/u/tmp3
$ vi xx.awk

/u/tmp3
$ sh xx.awk < infile > outfile
xx.awk: line 2: syntax error near unexpected token `/\r\n/,"\r"'
xx.awk: line 2: `gsub(/\r\n/,"\r") + 1'

Re: Convert CR LF to CR

<sca10b$m1l$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4058&group=comp.unix.shell#4058

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 12:28:42 -0500
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <sca10b$m1l$1@dont-email.me>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me>
<5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Jul 2021 17:28:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9beb3e3dd0b463cc6cab0062b0d90ac4";
logging-data="22581"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kLJlUSRQqkIFVqsR+0zFI"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:I0GzGiAwIc553cx1HxGxFawruBY=
In-Reply-To: <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210709-0, 7/8/2021), Outbound message
 by: Ed Morton - Fri, 9 Jul 2021 17:28 UTC

On 7/9/2021 11:59 AM, Harry wrote:
> On Friday, July 9, 2021 at 9:30:25 AM UTC-7, Ed Morton wrote:
>> On 7/9/2021 11:19 AM, Harry wrote:
>>> I have a text file that need to covert CR LF to CR.
>>>
>>> Sample input
>>> --
>>> LF
>>> LF
>>> Line 1 CR LF
>>> Line 2 CR LF
>>> LF
>>> LF
>>> LF
>>> Line 3 CR LF
>>> ...
>>> --
>>>
>>> Expected output
>>> --
>>> LF
>>> LF
>>> Line 1 CR
>>> Line 2 CR
>>> LF
>>> LF
>>> LF
>>> Line 3 CR
>>> ...
>>> --
>>>
>>> I have tried the following, but the output file has no change.
>>>
>>> sed -e 's#\r\n#\r#g' < infile > outfile
>>> sed -e 's#\x0D\x0A#\x0D#g' < infile > outfile
>>>
>>> Any suggestion?
>>>
>>> TIA
>>>
>> If that first sed command didn't do it then your input file isn't as
>> expected, assuming you don't REALLY have a blank char between each CR
>> and LF as your sample input shows (i.e. you have CRLF, not CR LF). Run
>> `cat -Ev` on your input file and copy/paste the output here.
>>
>> Ed.
>
> Here you go ...
>
> $ sed -e 's#\r\n#\r#g' < infile > outfile

Ah, I missed it first time but you're including `\n` in the regexp.
Replace that with `$` as the `\n` has already been consumed by sed
before the regexp is applied to the line so what you really want to
match is just a `\r` at the end of a line:

$ sed 's/\r$//' infile | cat -Ev
$ $
MSH|blablabla$
OBX|blablabla$
$ $
$ MSH|blablabla$
OBX|blablabla$
$ $
$ $

Regards,

Ed.

Re: Convert CR LF to CR

<325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4059&group=comp.unix.shell#4059

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:5444:: with SMTP id h4mr37378868qvt.14.1625852211742;
Fri, 09 Jul 2021 10:36:51 -0700 (PDT)
X-Received: by 2002:ad4:4187:: with SMTP id e7mr10952530qvp.0.1625852211520;
Fri, 09 Jul 2021 10:36:51 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 10:36:51 -0700 (PDT)
In-Reply-To: <sca10b$m1l$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me> <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 17:36:51 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 17:36 UTC

On Friday, July 9, 2021 at 10:28:48 AM UTC-7, Ed Morton wrote:

> $ sed 's/\r$//' infile | cat -Ev

Outfile now looks like this, but it is not what I want. I need "blablabla CR" instead of "blablabla LF".
--
LF
LF
MSH|blablabla LF
OBX|blablabla LF
LF
LF
LF
MSH|blablabla
OBX|blablabla
LF
LF
LF
--

Re: Convert CR LF to CR

<f9763584-608f-4cef-9d23-98de69795e97n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4060&group=comp.unix.shell#4060

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a0c:bf4b:: with SMTP id b11mr38264390qvj.11.1625852405117;
Fri, 09 Jul 2021 10:40:05 -0700 (PDT)
X-Received: by 2002:ac8:6654:: with SMTP id j20mr24129847qtp.284.1625852404979;
Fri, 09 Jul 2021 10:40:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 10:40:04 -0700 (PDT)
In-Reply-To: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f9763584-608f-4cef-9d23-98de69795e97n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 17:40:05 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 17:40 UTC

On Friday, July 9, 2021 at 9:19:10 AM UTC-7, Harry wrote:

The infile is uuencoded below, also rot13'ed because I could not post without the later.
Anyone could try this infile.

TIA

$ uuencode infile - | rot13
ortva 770 -
Z"@V-4GN\8SDN8SDN8SDN#0V/0RN\8SDN8SDN8SDN#0U*"@V-4GN\8SDN8SDN
78SDN#0V/0RN\8SDN8SDN8SDN#0U*"@U`
` raq

Re: Convert CR LF to CR

<scabn8$ldu$1@dont-email.me>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4061&group=comp.unix.shell#4061

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 15:31:36 -0500
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <scabn8$ldu$1@dont-email.me>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me>
<5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me>
<325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 9 Jul 2021 20:31:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="eae0b01739f24713726da38456f33b13";
logging-data="21950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pniXwh3FS0sCzPUpklI2D"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:nV+upc+IPKoyO8F9S7L9csUjPO8=
In-Reply-To: <325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210709-0, 7/8/2021), Outbound message
 by: Ed Morton - Fri, 9 Jul 2021 20:31 UTC

On 7/9/2021 12:36 PM, Harry wrote:
> On Friday, July 9, 2021 at 10:28:48 AM UTC-7, Ed Morton wrote:
>
>> $ sed 's/\r$//' infile | cat -Ev
>
> Outfile now looks like this, but it is not what I want. I need "blablabla CR" instead of "blablabla LF".
> --
> LF
> LF
> MSH|blablabla LF
> OBX|blablabla LF
> LF
> LF
> LF
> MSH|blablabla
> OBX|blablabla
> LF
> LF
> LF
> --
>

OK, sorry, now I understand. I've never seen anyone ask for CRLF to
become CR before, it's always LF. Using GNU sed for `-z` to read the
whole file as a single string:

$ sed -z 's/\r\n/\r/g' infile | cat -Ev
$ $
MSH|blablabla^MOBX|blablabla^M$
$ $
MSH|blablabla^MOBX|blablabla^M$
$ $

Regards,

Ed.

Re: Convert CR LF to CR

<02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4062&group=comp.unix.shell#4062

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:45c6:: with SMTP id v6mr11519644qvt.38.1625864676201;
Fri, 09 Jul 2021 14:04:36 -0700 (PDT)
X-Received: by 2002:a05:622a:14c9:: with SMTP id u9mr21588917qtx.219.1625864676067;
Fri, 09 Jul 2021 14:04:36 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 14:04:35 -0700 (PDT)
In-Reply-To: <scabn8$ldu$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me> <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me> <325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
<scabn8$ldu$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 21:04:36 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 27
 by: Harry - Fri, 9 Jul 2021 21:04 UTC

On Friday, July 9, 2021 at 1:31:41 PM UTC-7, Ed Morton wrote:

> OK, sorry, now I understand. I've never seen anyone ask for CRLF to
> become CR before, it's always LF. Using GNU sed for `-z` to read the
> whole file as a single string:
>
> $ sed -z 's/\r\n/\r/g' infile | cat -Ev
> $
> $
> MSH|blablabla^MOBX|blablabla^M$
> $
> $
> MSH|blablabla^MOBX|blablabla^M$
> $
> $

Ed, it is almost there. the first (MSH) lines end with CR.
But the second (OBX) lines still end with CR LF.

I need to make the lines end with CR because they are HL7 messages,
which are Health care messages which have CR as segment separators.

I search the web for dos2mac with no aval, of course dos2unix and unix2dos are there.
In the old days, Apple computer has all line ended with CR.

Please help me with making all lines (MSH, OBX) lines work.

Thanks

Re: Convert CR LF to CR

<87r1g76vqq.fsf@nosuchdomain.example.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4063&group=comp.unix.shell#4063

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 09 Jul 2021 14:08:29 -0700
Organization: None to speak of
Lines: 48
Message-ID: <87r1g76vqq.fsf@nosuchdomain.example.com>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="cc70e79fb5c7f99fe724fb3cbc0d4288";
logging-data="28280"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++xDYIQ94PBJWkJU/AHsRj"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ctxAmqagUNv2NrcFVY65zjdSSDY=
sha1:Bn0OWrXfee3Ze4bWwhCpikwjiMY=
 by: Keith Thompson - Fri, 9 Jul 2021 21:08 UTC

Harry <harryooopotter@hotmail.com> writes:
> I have a text file that need to covert CR LF to CR.
>
> Sample input
> --
> LF
> LF
> Line 1 CR LF
> Line 2 CR LF
> LF
> LF
> LF
> Line 3 CR LF
> ...
> --
>
> Expected output
> --
> LF
> LF
> Line 1 CR
> Line 2 CR
> LF
> LF
> LF
> Line 3 CR
> ...
> --
>
> I have tried the following, but the output file has no change.
>
> sed -e 's#\r\n#\r#g' < infile > outfile
> sed -e 's#\x0D\x0A#\x0D#g' < infile > outfile
>
> Any suggestion?

I'm curious why you'd want that. Using just CR as a line ending is
rare; the most recent example I can think of is MacOS before OSX.
And I can't really think of a good reason to want different endings
on different lines in the same file.

Not saying it's wrong, but it's unusual (and I'm wondering if more
information about why you need this might lead to a better solution).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Convert CR LF to CR

<9ff7ce8b-b192-4d97-a446-c33fec5e1136n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4064&group=comp.unix.shell#4064

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:11cf:: with SMTP id n15mr35697719qtk.256.1625865052547;
Fri, 09 Jul 2021 14:10:52 -0700 (PDT)
X-Received: by 2002:ac8:4741:: with SMTP id k1mr35663378qtp.374.1625865052412;
Fri, 09 Jul 2021 14:10:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 14:10:52 -0700 (PDT)
In-Reply-To: <02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me> <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me> <325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
<scabn8$ldu$1@dont-email.me> <02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9ff7ce8b-b192-4d97-a446-c33fec5e1136n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 21:10:52 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 21:10 UTC

On Friday, July 9, 2021 at 2:04:38 PM UTC-7, Harry wrote:
> On Friday, July 9, 2021 at 1:31:41 PM UTC-7, Ed Morton wrote:
>
> > OK, sorry, now I understand. I've never seen anyone ask for CRLF to
> > become CR before, it's always LF. Using GNU sed for `-z` to read the
> > whole file as a single string:
> >
> > $ sed -z 's/\r\n/\r/g' infile | cat -Ev
> > $
> > $
> > MSH|blablabla^MOBX|blablabla^M$
> > $
> > $
> > MSH|blablabla^MOBX|blablabla^M$
> > $
> > $
> Ed, it is almost there. the first (MSH) lines end with CR.
> But the second (OBX) lines still end with CR LF.
>
> I need to make the lines end with CR because they are HL7 messages,
> which are Health care messages which have CR as segment separators.
>
> I search the web for dos2mac with no aval, of course dos2unix and unix2dos are there.
> In the old days, Apple computer has all line ended with CR.
>
> Please help me with making all lines (MSH, OBX) lines work.
>
> Thanks

Ed,
Sorry, actually it works.
The outfile now becomes this : the LF on OBX came from the next LF line.
--
LF
LF
MSH|bla CR
OBX|bla CR LF
LF
LF
,,,
--

Re: Convert CR LF to CR

<20210709142658.883@kylheku.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4065&group=comp.unix.shell#4065

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 21:29:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20210709142658.883@kylheku.com>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Injection-Date: Fri, 9 Jul 2021 21:29:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ecabee45d7d2d905d26faa4521428a5e";
logging-data="11805"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lxnkD3dcPRuhxGpL9n7krf+6V2MJRddE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:voyGskj/mn7/Taub0QKJ5Y7NRsc=
 by: Kaz Kylheku - Fri, 9 Jul 2021 21:29 UTC

On 2021-07-09, Harry <harryooopotter@hotmail.com> wrote:
> I have a text file that need to covert CR LF to CR.
>
> Sample input
> --
> LF
> LF
> Line 1 CR LF
> Line 2 CR LF
> LF
> LF
> LF
> Line 3 CR LF
> ...
> --
>
> Expected output
> --
> LF
> LF
> Line 1 CR
> Line 2 CR
> LF
> LF
> LF
> Line 3 CR
> ...
> --

awk '/\r$/ { printf("%s", $0); next } 1'

Explanation: note that the requirements amount to processing an ordinary
Unix-style LF-terminated file such that:

- Every line that ends in CR is output without the terminating LF.

- All other lines are are passed through.

All we have to do is match lines ending in a CR and output them
using printf("%s", ...) without any newline.

Re: Convert CR LF to CR

<b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4066&group=comp.unix.shell#4066

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ae9:d618:: with SMTP id r24mr33250080qkk.433.1625866627902;
Fri, 09 Jul 2021 14:37:07 -0700 (PDT)
X-Received: by 2002:a05:620a:1278:: with SMTP id b24mr15351506qkl.30.1625866627760;
Fri, 09 Jul 2021 14:37:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 14:37:07 -0700 (PDT)
In-Reply-To: <20210709142658.883@kylheku.com>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com> <20210709142658.883@kylheku.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 21:37:07 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 21:37 UTC

On Friday, July 9, 2021 at 2:29:19 PM UTC-7, Kaz Kylheku wrote:

> awk '/\r$/ { printf("%s", $0); next } 1'
>
> Explanation: note that the requirements amount to processing an ordinary
> Unix-style LF-terminated file such that:
>
> - Every line that ends in CR is output without the terminating LF.
>
> - All other lines are are passed through.
>
> All we have to do is match lines ending in a CR and output them
> using printf("%s", ...) without any newline.

Kaz,

Your solution works as well as Ed's.
BTW, what is the "1" mean/for at the end pf the awk cmd ?

Thanks

Re: Convert CR LF to CR

<8e7e293f-6a11-4970-8e7d-3c42b75c5e6en@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4067&group=comp.unix.shell#4067

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:688f:: with SMTP id d137mr37329532qkc.453.1625867586349;
Fri, 09 Jul 2021 14:53:06 -0700 (PDT)
X-Received: by 2002:ae9:ed11:: with SMTP id c17mr4111675qkg.111.1625867586223;
Fri, 09 Jul 2021 14:53:06 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 14:53:06 -0700 (PDT)
In-Reply-To: <87r1g76vqq.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com> <87r1g76vqq.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8e7e293f-6a11-4970-8e7d-3c42b75c5e6en@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 21:53:06 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 21:53 UTC

On Friday, July 9, 2021 at 2:08:34 PM UTC-7, Keith Thompson wrote:

> I'm curious why you'd want that. Using just CR as a line ending is
> rare; the most recent example I can think of is MacOS before OSX.
> And I can't really think of a good reason to want different endings
> on different lines in the same file.

Keith

To make my story short ...

I am working in Healthcare where my role is an Interface analyst.
Health Care messages (HL7) come from other foreign Healthcare systems
and post to our Hospital Information system.

Previously I used Oracle's sqldeveloper to query manually the HL7 messages stored
in our database, and I then use some shell scripts to massages the SQL output
so to do some of my task.

Oracle has now another tool called sqlcl, which allows the query to be automated.
But the sqlcl output have some issues (like showing HL7 messages ended with CR LF
instead of just CR as the segment separators).

So, that is the reason I need a shell script fix.

Hope this explains my reason, without confusing more ....

Thanks

Re: Convert CR LF to CR

<op.0599zseoa3w0dxdave@hodgins.homeip.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4068&group=comp.unix.shell#4068

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 09 Jul 2021 17:58:30 -0400
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <op.0599zseoa3w0dxdave@hodgins.homeip.net>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me>
<5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me>
<325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
<scabn8$ldu$1@dont-email.me>
<02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="ce26e50f2ee0634113b26b32eeffca9d";
logging-data="31975"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19yct+DTAwCadvD14z9f640foWSH/iNyHY="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:hlOEsN8jDjKUxCWUaGj73iIYDKg=
 by: David W. Hodgins - Fri, 9 Jul 2021 21:58 UTC

On Fri, 09 Jul 2021 17:04:35 -0400, Harry <harryooopotter@hotmail.com> wrote:
> I search the web for dos2mac with no aval, of course dos2unix and unix2dos are there.

$ cat test
one
two
$ unix2dos -n test test.dos
unix2dos: converting file test to file test.dos in DOS format...
$ unix2mac -n test test.mac
unix2mac: converting file test to file test.mac in Mac format...
$ hexdump test
0000000 6e6f 0a65 7774 0a6f
0000008
$ hexdump test.dos
0000000 6e6f 0d65 740a 6f77 0a0d
000000a
$ hexdump test.mac
0000000 6e6f 0d65 7774 0d6f
0000008
$ rpm -q -f /usr/bin/unix2mac
dos2unix-7.4.2-1.mga8
$ rpm -q -i dos2unix|grep ^URL
URL : http://www.xs4all.nl/~waterlan/dos2unix.html

This is on a Mageia 8 x86_64 installation.

Regards, Dave Hodgins

--
Change dwhodgins@nomail.afraid.org to davidwhodgins@teksavvy.com for
email replies.

Re: Convert CR LF to CR

<scai4c$39rom$1@news.xmission.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4069&group=comp.unix.shell#4069

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 22:21:00 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <scai4c$39rom$1@news.xmission.com>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com> <20210709142658.883@kylheku.com> <b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>
Injection-Date: Fri, 9 Jul 2021 22:21:00 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3469078"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 9 Jul 2021 22:21 UTC

In article <b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>,
Harry <harryooopotter@hotmail.com> wrote:
....
>Your solution works as well as Ed's.

High praise, indeed.

--
"Every time Mitt opens his mouth, a swing state gets its wings."

(Should be on a bumper sticker)

Re: Convert CR LF to CR

<729d43fc-fb00-48d2-826a-4bb48a2ec02cn@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4070&group=comp.unix.shell#4070

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:9e07:: with SMTP id h7mr16341492qke.481.1625869329140;
Fri, 09 Jul 2021 15:22:09 -0700 (PDT)
X-Received: by 2002:ac8:7a61:: with SMTP id w1mr16619820qtt.176.1625869329002;
Fri, 09 Jul 2021 15:22:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 15:22:08 -0700 (PDT)
In-Reply-To: <op.0599zseoa3w0dxdave@hodgins.homeip.net>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me> <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me> <325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
<scabn8$ldu$1@dont-email.me> <02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
<op.0599zseoa3w0dxdave@hodgins.homeip.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <729d43fc-fb00-48d2-826a-4bb48a2ec02cn@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 22:22:09 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 22:22 UTC

On Friday, July 9, 2021 at 2:59:36 PM UTC-7, David W. Hodgins wrote:
> On Fri, 09 Jul 2021 17:04:35 -0400, Harry <harryoo...@hotmail.com> wrote:
> > I search the web for dos2mac with no aval, of course dos2unix and unix2dos are there.
> $ cat test
> one
> two
> $ unix2dos -n test test.dos
> unix2dos: converting file test to file test.dos in DOS format...
> $ unix2mac -n test test.mac
> unix2mac: converting file test to file test.mac in Mac format...

I'd been there, d/l dos2unix-7.4.2-win64.zip.
4 exe there :

dos2unix.exe
unix2dos.exe
mac2unix.exe
unix2mac.exe

But no dos2mac.exe nor mac2dos.exe.

Re: Convert CR LF to CR

<op.06abwtjaa3w0dxdave@hodgins.homeip.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4071&group=comp.unix.shell#4071

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: dwhodg...@nomail.afraid.org (David W. Hodgins)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 09 Jul 2021 18:39:55 -0400
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <op.06abwtjaa3w0dxdave@hodgins.homeip.net>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me>
<5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me>
<325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
<scabn8$ldu$1@dont-email.me>
<02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
<op.0599zseoa3w0dxdave@hodgins.homeip.net>
<729d43fc-fb00-48d2-826a-4bb48a2ec02cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="2b8a8895ae5c2568c0397970b7a4497b";
logging-data="25492"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+w+2GE/LDOUtyeY5w69XVjAUKwByQ2JKg="
User-Agent: Opera Mail/12.16 (Linux)
Cancel-Lock: sha1:6QFAz0EOH8JTM0vp3qz92vHon+0=
 by: David W. Hodgins - Fri, 9 Jul 2021 22:39 UTC

On Fri, 09 Jul 2021 18:22:08 -0400, Harry <harryooopotter@hotmail.com> wrote:
> I'd been there, d/l dos2unix-7.4.2-win64.zip.
> 4 exe there :
>
> dos2unix.exe
> unix2dos.exe
> mac2unix.exe
> unix2mac.exe
>
> But no dos2mac.exe nor mac2dos.exe.

Run it in two steps. Dos to unix, and then unix to mac or vice-versa. Not ideal, but
easy to do.

Regards, Dave Hodgins

--
Change dwhodgins@nomail.afraid.org to davidwhodgins@teksavvy.com for
email replies.

Re: Convert CR LF to CR

<2dfcec57-577f-44ac-9f09-1f31c6ceff00n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4072&group=comp.unix.shell#4072

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:57ac:: with SMTP id g12mr1623871qvx.32.1625871697311;
Fri, 09 Jul 2021 16:01:37 -0700 (PDT)
X-Received: by 2002:ae9:d883:: with SMTP id u125mr39763030qkf.318.1625871697184;
Fri, 09 Jul 2021 16:01:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Fri, 9 Jul 2021 16:01:37 -0700 (PDT)
In-Reply-To: <op.06abwtjaa3w0dxdave@hodgins.homeip.net>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<sc9tit$ohj$1@dont-email.me> <5abd1e5f-8785-490b-9955-e6c20f5f9119n@googlegroups.com>
<sca10b$m1l$1@dont-email.me> <325bc60b-d2fc-412e-8d86-d39af6315f7cn@googlegroups.com>
<scabn8$ldu$1@dont-email.me> <02ad8bdd-fabe-4a04-a08c-4ab2070ec1e7n@googlegroups.com>
<op.0599zseoa3w0dxdave@hodgins.homeip.net> <729d43fc-fb00-48d2-826a-4bb48a2ec02cn@googlegroups.com>
<op.06abwtjaa3w0dxdave@hodgins.homeip.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2dfcec57-577f-44ac-9f09-1f31c6ceff00n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Fri, 09 Jul 2021 23:01:37 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Fri, 9 Jul 2021 23:01 UTC

On Friday, July 9, 2021 at 3:47:56 PM UTC-7, David W. Hodgins wrote:

> > But no dos2mac.exe nor mac2dos.exe.
> Run it in two steps. Dos to unix, and then unix to mac or vice-versa. Not ideal, but
> easy to do.

Dave

It would not work for me, as the second step unix2mac will change the
blank LF lines to CR lines, which is not what I want.

Thanks

Re: Convert CR LF to CR

<20210709161810.593@kylheku.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4073&group=comp.unix.shell#4073

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 9 Jul 2021 23:19:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20210709161810.593@kylheku.com>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<20210709142658.883@kylheku.com>
<b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>
Injection-Date: Fri, 9 Jul 2021 23:19:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3945314f45125b89897a2adae2fcb6bf";
logging-data="7017"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19I8/CvuyNaUxqxOFfzT+tT6Gjg9DN1Zak="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:SF/oyu5Jtbe+68JL1fcwFYG2qWA=
 by: Kaz Kylheku - Fri, 9 Jul 2021 23:19 UTC

On 2021-07-09, Harry <harryooopotter@hotmail.com> wrote:
> On Friday, July 9, 2021 at 2:29:19 PM UTC-7, Kaz Kylheku wrote:
>
>> awk '/\r$/ { printf("%s", $0); next } 1'
>>
>> Explanation: note that the requirements amount to processing an ordinary
>> Unix-style LF-terminated file such that:
>>
>> - Every line that ends in CR is output without the terminating LF.
>>
>> - All other lines are are passed through.
>>
>> All we have to do is match lines ending in a CR and output them
>> using printf("%s", ...) without any newline.
>
> Kaz,
>
> Your solution works as well as Ed's.

In one try, using code that can reasonably be expected to work on a SVR4
Unix box from 1988.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Convert CR LF to CR

<87k0lz6my1.fsf@nosuchdomain.example.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4074&group=comp.unix.shell#4074

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Fri, 09 Jul 2021 17:18:30 -0700
Organization: None to speak of
Lines: 73
Message-ID: <87k0lz6my1.fsf@nosuchdomain.example.com>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="7dee47812cca3c2bd649333529ffcd37";
logging-data="21521"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19AA00LRR6p3XdB7vOg9zSF"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:8YRovaSKe4V/vMbD70vhWfkpFTM=
sha1:ymPi8ZV6JMINaLn+JRhGLd6VBPE=
 by: Keith Thompson - Sat, 10 Jul 2021 00:18 UTC

Harry <harryooopotter@hotmail.com> writes:
> I have a text file that need to covert CR LF to CR.
>
> Sample input
> --
> LF
> LF
> Line 1 CR LF
> Line 2 CR LF
> LF
> LF
> LF
> Line 3 CR LF
> ...
> --
>
> Expected output
> --
> LF
> LF
> Line 1 CR
> Line 2 CR
> LF
> LF
> LF
> Line 3 CR
> ...
> --
>
> I have tried the following, but the output file has no change.
>
> sed -e 's#\r\n#\r#g' < infile > outfile
> sed -e 's#\x0D\x0A#\x0D#g' < infile > outfile
>
> Any suggestion?

My first suggestion is to stop thinking of the chunks of your input and
output files as "lines". The whole thing is a sequence of cahracters.
Your goal is to copy that sequence, replacing every occurrence of CR LF
by CR. while copying any LF characters *not* preceded by CR unchanged.

Here's a C program that should do the job. It reads from stdin and
writes to stdout. (Of course this requires having access to a C
development environment so you can build and run the program.)

#include <stdio.h>
int main(void) {
int prev = 0;
int c;
while ((c = getchar()) != EOF) {
if (! (prev == '\r' && c == '\n')) {
putchar(c);
}
prev = c;
}
}

Don't worry about the performance of reading and writing a character at
a time. It's all buffered.

It should do what you want if you run it in a Unix-like environment
(which seems a safe assumption given where you posted).

(Under Windows CRLF pairs would be translated to LF on input, and LF to
CRLF on output. You could avoid that by using binary streams for input
and output, avoiding translation of line terminators. But Unix treats
text and binary files the same way, so it shouldn't be necessary for
you.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Convert CR LF to CR

<zsdP8S5dxCsfgn03B@bongo-ra.co>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4076&group=comp.unix.shell#4076

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!Lsq9Ulyii8Zln50ye03obQ.user.gioia.aioe.org.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Sat, 10 Jul 2021 11:02:50 +0000 (UTC)
Organization: Aioe.org NNTP Server
Lines: 38
Message-ID: <zsdP8S5dxCsfgn03B@bongo-ra.co>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com> <20210709142658.883@kylheku.com> <b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>
NNTP-Posting-Host: Lsq9Ulyii8Zln50ye03obQ.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@aioe.org
X-Notice: Filtered by postfilter v. 0.9.2
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Sat, 10 Jul 2021 11:02 UTC

On Fri, 9 Jul 2021 14:37:07 -0700 (PDT)
Harry <harryooopotter@hotmail.com> wrote:
> On Friday, July 9, 2021 at 2:29:19 PM UTC-7, Kaz Kylheku wrote:
>
> > awk '/\r$/ { printf("%s", $0); next } 1'
> >
> > Explanation: note that the requirements amount to processing an ordinary
> > Unix-style LF-terminated file such that:
> >
> > - Every line that ends in CR is output without the terminating LF.
> >
> > - All other lines are are passed through.
> >
> > All we have to do is match lines ending in a CR and output them
> > using printf("%s", ...) without any newline.
>
> Kaz,
>
> Your solution works as well as Ed's.
> BTW, what is the "1" mean/for at the end pf the awk cmd ?

It is a pattern. It means always match (1 stands for true ; one of the many
ways to indicate boolean true in AWK) and , since no explicit action is given
, the default action will happen which is print the whole line. So if a line
matches the pattern /\r$/ then { printf("%s", $0); next } will be executed
and the next command will load the next line and start matching the
patterns from the beginning ; if /\r$/ does not match then the next
"pattern" is tried which is 1 which always matches so the whole line gets
printed.

By the way , for this kind of thing the first thing to cross my mind would be
to use C because for this problem it actually provides the clearest code. So
something like Keith's code in <87k0lz6my1.fsf@nosuchdomain.example.com>
would be my preference.

--
The famous --do-what-I-mean-not-what-I-write compiler switch.
https://lwn.net/Articles/508991/

Re: Convert CR LF to CR

<scbv49$fi0$1@news-1.m-online.net>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4077&group=comp.unix.shell#4077

 copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Convert CR LF to CR
Date: Sat, 10 Jul 2021 13:08:57 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 18
Message-ID: <scbv49$fi0$1@news-1.m-online.net>
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<20210709142658.883@kylheku.com>
<b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>
<zsdP8S5dxCsfgn03B@bongo-ra.co>
NNTP-Posting-Host: 2001:a61:241e:cc01:d82c:c9b2:3d0a:40f7
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1625915337 15936 2001:a61:241e:cc01:d82c:c9b2:3d0a:40f7 (10 Jul 2021 11:08:57 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Sat, 10 Jul 2021 11:08:57 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
In-Reply-To: <zsdP8S5dxCsfgn03B@bongo-ra.co>
 by: Janis Papanagnou - Sat, 10 Jul 2021 11:08 UTC

On 10.07.2021 13:02, Spiros Bousbouras wrote:
>
> By the way , for this kind of thing the first thing to cross my mind would be
> to use C because for this problem it actually provides the clearest code.

And likely also the fastest, which would matter if - as I would expect
with health data - a lot of data has to be handled.

> So
> something like Keith's code in <87k0lz6my1.fsf@nosuchdomain.example.com>
> would be my preference.

For small data sets a quick awk prototype solution might be preferable,
and also if there's no C development environment available in the OP's
working context.

Janis

Re: Convert CR LF to CR

<5f06fd91-f116-438e-9e21-d9002ab55df2n@googlegroups.com>

 copy mid

https://www.novabbs.com/devel/article-flat.php?id=4080&group=comp.unix.shell#4080

 copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:13c4:: with SMTP id i4mr34082913qtj.136.1625927825286;
Sat, 10 Jul 2021 07:37:05 -0700 (PDT)
X-Received: by 2002:ac8:7c98:: with SMTP id y24mr15283749qtv.268.1625927825140;
Sat, 10 Jul 2021 07:37:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Sat, 10 Jul 2021 07:37:04 -0700 (PDT)
In-Reply-To: <zsdP8S5dxCsfgn03B@bongo-ra.co>
Injection-Info: google-groups.googlegroups.com; posting-host=96.49.148.18; posting-account=0cwH1wkAAACyHC8RuqgGpRum9kOwb46T
NNTP-Posting-Host: 96.49.148.18
References: <3ec51006-7355-44b5-a871-71c467c8605en@googlegroups.com>
<20210709142658.883@kylheku.com> <b053012b-041b-4882-9fb9-8b83663ffe31n@googlegroups.com>
<zsdP8S5dxCsfgn03B@bongo-ra.co>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5f06fd91-f116-438e-9e21-d9002ab55df2n@googlegroups.com>
Subject: Re: Convert CR LF to CR
From: harryooo...@hotmail.com (Harry)
Injection-Date: Sat, 10 Jul 2021 14:37:05 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Harry - Sat, 10 Jul 2021 14:37 UTC

On Saturday, July 10, 2021 at 4:02:56 AM UTC-7, Spiros Bousbouras wrote:

> > BTW, what is the "1" mean/for at the end pf the awk cmd ?

> It is a pattern. It means always match (1 stands for true ; one of the many
> ways to indicate boolean true in AWK) and , since no explicit action is given
> , the default action will happen which is print the whole line. So if a line
> matches the pattern /\r$/ then { printf("%s", $0); next } will be executed
> and the next command will load the next line and start matching the
> patterns from the beginning ; if /\r$/ does not match then the next
> "pattern" is tried which is 1 which always matches so the whole line gets
> printed.

Thanks for the explanation.

Pages:123
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor