[PLUG] Translating ^M to \n
Rodney W. Grimes
freebsd at gndrsh.dnsmgr.net
Tue Aug 13 00:43:56 UTC 2019
> On 8/12/19 4:34 PM, Rich Shepard wrote:
> > On Mon, 12 Aug 2019, Michael Ewan wrote:
> >
> >> tr is your friend
> >> tr '\013' '\n' < old_file > new_file
> >> this will probably work also
> >> tr '\r' '\n' < old_file > new_file
> >
> > Michael,
> >
> > As I've written, it should but doesn't.
> >
> > The smallest file can be downloaded from <https://tinyurl.com/y54p8xgv>.
>
> Looks like a mixture of line endings. I'm seeing both CR and LF in that
> file.
>
> [galens at toto ~]$ wc -l Downloads/hatchery_returns-2019-08-12.csv
> 102 Downloads/hatchery_returns-2019-08-12.csv
>
> Converting CR to LF and then counting lines yields 10801.
>
> There's also one instance of a CRLF at the end of the file.
>
> Perhaps there are some LF characters embedded in strings. I didn't
> bother to dive in any farther.
This looks like a file that was CRLF ending after it
has been mangled by a web download.... and was treated
as a text file type rather than a binary file so line
ending mangling did occur.
--
Rod Grimes rgrimes at freebsd.org
More information about the PLUG
mailing list