This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: Join command fails to output fields on input file with DOS line endings.
- From: "Andy Hall" <fixpertise-consulting at comcast dot net>
- To: <moss at cs dot umass dot edu>, <cygwin at cygwin dot com>
- Date: Tue, 23 Jul 2019 08:15:41 -0700
- Subject: RE: Join command fails to output fields on input file with DOS line endings.
- References: <009e01d540c6$c1b11d50$451357f0$@comcast.net> <ac58e313-bfbf-b245-6c80-58d59be23f47@cs.umass.edu>
> On 7/22/2019 12:59 PM, Eliot Moss wrote:
> On 7/22/2019 12:50 PM, Andy Hall wrote:
> > This behavior of join surprised me:
> >
> > $ join -1 3 <(echo a b col3 c d | unix2dos) <(echo col3 f2 f3 f4 f5)
> > f2 f3 f4 f5
> >
> > Join parses the input line well enough to execute the join, but the presence of the DOS line endings suppresses the
> > output of fields from the first input.
> >
> > Compare with
> >
> > $ join -1 3 <(echo a b col3 c d) <(echo col3 f2 f3 f4 f5)
> > col3 a b c d f2 f3 f4 f5
> >
> > which is correct.
> >
> > Here is a weirder example where the join field is missing and the output is reversed!
> >
> > NOK
> > $ join <(echo col F1 | unix2dos) <(echo col F2)
> > F2 F1
> >
> > OK
> > $ join <(echo col F1) <(echo col F2)
> > col F1 F2
>
> The lesson is: You're better off not using DOS line endings with Cygwin.
> It tends to do things the POSIX way, where the line ending is LF, not
> CR LF. Some things *may* work, but it's somewhat hit or miss ... EM
>
Right. But in this case, the last field of the first file contains a \r which
completely mangles the output.
But join appears to "work" if the lines of the second file are in DOS format.
E.g.
$ join <(echo col F1) <(echo col F2 | unix2dos)
col F1 F2
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple