~alpine/users

3 3

Windows/Dos ^M (CR/LF) removal on Alpine ash shell

Banibrata Dutta <banibrata.dutta@gmail.com>
Details
Message ID
<CALODqprPHi4Q284cAURfiB5KzzM-T4jZRPw83Vb_+E2KroL6zg@mail.gmail.com>
DKIM signature
missing
Download raw message
Hi,

What would be the recommended way to remove the Control-M (CR/LF
combination from DOS/Windows produced text file) in ash shell on Alpine ?
In bash, I could use sed and the Control-V+Control-M character to inject ^M
in the regex pattern to find/replace. That combination doesn't seem to work
on Alpine ash.

thanks
BD
Sébastien Maccagnoni <sebastien@maccagnoni.eu>
Details
Message ID
<CAEfdg1mSqyPi7jSg3=+BwZFg82JGKSvVzrDGwNQzeKG3MFsaHA@mail.gmail.com>
In-Reply-To
<CALODqprPHi4Q284cAURfiB5KzzM-T4jZRPw83Vb_+E2KroL6zg@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
Hello,

The dos2unix command, which is available in package dos2unix, would
probably do what you want.

Le mar. 23 févr. 2021 à 06:00, Banibrata Dutta <banibrata.dutta@gmail.com>
a écrit :

> What would be the recommended way to remove the Control-M (CR/LF
> combination from DOS/Windows produced text file) in ash shell on Alpine ?
> In bash, I could use sed and the Control-V+Control-M character to inject ^M
> in the regex pattern to find/replace. That combination doesn't seem to work
> on Alpine ash.
>


-- 
Sébastien
https://www.maccagnoni.eu/
Details
Message ID
<20210223110330.3aa0b3dd@ncopa-desktop.lan>
In-Reply-To
<CALODqprPHi4Q284cAURfiB5KzzM-T4jZRPw83Vb_+E2KroL6zg@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
On Tue, 23 Feb 2021 10:29:50 +0530
Banibrata Dutta <banibrata.dutta@gmail.com> wrote:

> Hi,
> 
> What would be the recommended way to remove the Control-M (CR/LF
> combination from DOS/Windows produced text file) in ash shell on Alpine ?
> In bash, I could use sed and the Control-V+Control-M character to inject ^M
> in the regex pattern to find/replace. That combination doesn't seem to work
> on Alpine ash.
> 
> thanks
> BD

you can do:

  tr -d '\015' < dos.txt > unix.txt

or:

  sed $'s/\r$//' < dos.txt > unix.txt

or use the mentioned dos2unix tool


-nc
Banibrata Dutta <banibrata.dutta@gmail.com>
Details
Message ID
<CALODqppS+aKJ98qLCvqgRgog9aRN__oALDXiELPf1+sQKxwUqw@mail.gmail.com>
In-Reply-To
<20210223110330.3aa0b3dd@ncopa-desktop.lan> (view parent)
DKIM signature
missing
Download raw message
Thanks a lot, Natanel and Sebastien.

On Tue, Feb 23, 2021 at 3:33 PM Natanael Copa <ncopa@alpinelinux.org> wrote:

> On Tue, 23 Feb 2021 10:29:50 +0530
> Banibrata Dutta <banibrata.dutta@gmail.com> wrote:
>
> > Hi,
> >
> > What would be the recommended way to remove the Control-M (CR/LF
> > combination from DOS/Windows produced text file) in ash shell on Alpine ?
> > In bash, I could use sed and the Control-V+Control-M character to inject
> ^M
> > in the regex pattern to find/replace. That combination doesn't seem to
> work
> > on Alpine ash.
> >
> > thanks
> > BD
>
> you can do:
>
>   tr -d '\015' < dos.txt > unix.txt
>
> or:
>
>   sed $'s/\r$//' < dos.txt > unix.txt
>
> or use the mentioned dos2unix tool
>
>
> -nc
>


-- 
regards,
Banibrata
http://www.linkedin.com/in/bdutta
http://twitter.com/edgeliving
Reply to thread Export thread (mbox)