Dear Gordon,

Perhaps the "-e" option of the join command is "If there is no field in the 
input, set the corresponding output field to STRING, but
only one field of STRING can be specified, and if the corresponding output 
field with no input is 2 If there is more than the field,
will you use the specified STRING iteratively?
Is this not a bug, but the specification of the join command?


>  -----Original Message-----
>  From: Goto, Ryoichi [mailto:[email protected]]
>  Sent: Friday, March 31, 2017 8:38 AM
>  To: 'Assaf Gordon' <[email protected]>
>  Cc: '[email protected]' <[email protected]>
>  Subject: RE: When specifying multiple elements with "-e" option of join 
> command
>  
>  Dear Gordon,
>  
>  Thank you for your reply.
>  
>  First, it is the field of File 2, but because of the editor it has become 
> four fields, but in fact
>  
>  ==> File 2 <==
>     [email protected] 1 password-1
>     [email protected] 2 password-2
>  
>  I thought that I wanted to match the number of fields combined with the next 
> option to File 2 in three fields.
>   "-o 0 2.2 2.3"
>  
>  
>  Next is the correct answer.
>  
>  [File 1]
>  [email protected]
>  [email protected]
>  [email protected]
>  -
>  [File 2]
>  [email protected]   1 password-1
>  [email protected] 2 password-2
>  -
>  [Expected results]
>  [email protected]   0 PASSWORD-0
>  [email protected] 2 password-2
>  [email protected]   1 password-1
>  
>  I understand that processing is possible using awk or sed. However, I would 
> like to know about the specification of "join
>  -e" option, whether there is a function to supplement two fields missing in 
> File1.
>  
>  Thank you.
>  
>  >  -----Original Message-----
>  >  From: Assaf Gordon [mailto:[email protected]]
>  >  Sent: Friday, March 31, 2017 12:09 AM
>  >  To: Goto, Ryoichi <[email protected]>
>  >  Cc: [email protected]
>  >  Subject: Re: When specifying multiple elements with "-e" option of
>  > join command
>  >
>  >  Hello,
>  >
>  >  > On Mar 30, 2017, at 01:41, Goto, Ryoichi <[email protected]> wrote:
>  >  >
>  >  > [...]
>  >  > I tried executing the following command, but the record
>  > "[email protected]" which exists only in File 1 has two pairs of  character 
> strings specified by "-e" output.
>  >  > $ Join -1 1 - o 0 2.2 2.3 - a 1 - e "0 PASSWORD 0" <(sort File 1)
>  > > <(sort File 2)  >  > [Actual result]  > Jiro @ yahoo.jp 0 PASSWORD 0
>  > 0 PASSWORD 0 [email protected] 2 password 2  > [email protected] 1 password
>  > 1  >  > If you remove the double quotes from the command line you ran,
>  > "join: extra operator '/ dev / fd / 62'" and an unknown  error will be
>  > displayed and say "- e 0 - e PASSWORD 0" The syntax is also an error.
>  >
>  >  The "-e" parameter fills missing fields with the given value. The
>  > second file has 4 fields, and after the join 3 fields  are missing - so 
> the string you've set to "-e" appears multiple
>  times.
>  >
>  >  Notice the following:
>  >
>  >    $ head *
>  >    ==> file1 <==
>  >    [email protected]
>  >    [email protected]
>  >    [email protected]
>  >
>  >    ==> file2 <==
>  >    [email protected] 1 password 1
>  >    [email protected] 2 password 2
>  >
>  >    $ join -o auto -e MISSING -a 1 -j1 <(sort file1) <(sort file2)
>  >    [email protected] 2 password 2
>  >    [email protected] MISSING MISSING MISSING
>  >    [email protected] 1 password 1
>  >
>  >  I can suggest two work-arounds, which work with your specific files:
>  >
>  >  Option #1:
>  >  Because 'file1' has only one field, we know implicitly that any
>  > joined line which still has one field in the output did  not have a 
> matching record in the second file.
>  >  Then, a simple AWK script can add the needed password:
>  >
>  >    $ join -a 1 -j1 <(sort file1) <(sort file2)
>  >    [email protected] 2 password 2
>  >    [email protected]
>  >    [email protected] 1 password 1
>  >
>  >    $ join -a 1 -j1 <(sort file1) <(sort file2) \
>  >       | awk 'NF==1 { print $0, "0 password 0" } NF!=1 { print }'
>  >    [email protected] 2 password 2
>  >    [email protected] 0 password 0
>  >    [email protected] 1 password 1
>  >
>  >
>  >  Option #2:
>  >  Use "-e" to mark lines with missing values, then detect and replace then 
> with sed:
>  >
>  >    $ join -o auto -e XX -a 1 -j1 <(sort file1) <(sort file2)
>  >    [email protected] 2 password 2
>  >    [email protected] XX XX XX
>  >    [email protected] 1 password 1
>  >
>  >    $ join -o auto -e XX -a 1 -j1 <(sort file1) <(sort file2) \
>  >          | sed 's/XX XX XX/0 password 0/'
>  >    [email protected] 2 password 2
>  >    [email protected] 0 password 0
>  >    [email protected] 1 password 1
>  >
>  >
>  >  Of course these are just examples which can be used as basis for similar 
> variations.
>  >
>  >  Hope this helps,
>  >
>  >  regards,
>  >   - assaf



Reply via email to