-1
\$\begingroup\$

Inspired by what I'm doing at work right now.

Your program should take one parameter, the path to the file

It should convert all the windows style newlines (\r\n) to unix style (\n) and write the result back to the file

\$\endgroup\$
5
  • 3
    \$\begingroup\$ Can we assume that the file never contains \r without \n immediately following? \$\endgroup\$
    – Adám
    Commented Dec 17, 2020 at 10:08
  • 1
    \$\begingroup\$ Related. \$\endgroup\$
    – Bubbler
    Commented Dec 17, 2020 at 10:16
  • 1
    \$\begingroup\$ As this is a subset of the problem in the question linked by @Bubbler, I’ve voted to close as a duplicate \$\endgroup\$ Commented Dec 17, 2020 at 10:21
  • \$\begingroup\$ I agree it's a duplicate. Too bad search didn't find it \$\endgroup\$ Commented Dec 17, 2020 at 10:33
  • \$\begingroup\$ @Adám yes you can \$\endgroup\$ Commented Dec 17, 2020 at 10:34

1 Answer 1

0
\$\begingroup\$

APL (Dyalog Unicode), 22 bytes

Anonymous tacit prefix function.

10@3∘⎕NGET⎕NPUT{⍵1}

Try it online!

⎕NGET get content,encoding,line-ending from argument file

10@3∘ replace the third element (line ending) with 10, meaning \n

⎕NPUT put that into…

{⍵1} the file name followed by an overwrite flag

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.