This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Join command fails to output fields on input file with DOS line endings.

Greetings, Andy Hall!

> 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!

> $ join <(echo col F1 | unix2dos) <(echo col F2)
>  F2 F1

This makes perfect sense and actually explains what you see.
1. ("col", "F1\r") & ("col", "F2")
2. ("col", "F1\r", "F2")
3. printing "col F1\r F2"
4. obvious result: "col F1", then \r place cursor at the beginning of the
line, then " F2" overprints the line beginning.
5. observed result: " F2 F1"

> OK
> $ join <(echo col F1) <(echo col F2)
> col F1 F2

As Eliot said, don't do that.

With best regards,
Andrey Repin
Tuesday, July 23, 2019 9:45:05

Sorry for my terrible english...

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]