[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replacement for 'join'?
From: |
Bernhard Voelker |
Subject: |
Re: replacement for 'join'? |
Date: |
Tue, 6 Apr 2021 00:48:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 |
On 4/5/21 1:06 AM, Bruno Haible wrote:
> Alpine Linux does not have the 'join' program.
> The GCS [1] don't list it among the essential utilities.
FWIW: join(1) is required by POSIX [1]:
[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/join.html
> So, what kind of replacement for it would you recommend?
> My use-case is
>
> join -v 1 FILE1 FILE2
Maybe awk?
$ awk -v keyfile=file2 '
BEGIN { while ((getline < keyfile) > 0) k[$1]=1 }
!k[$1]
' file1
or
$ awk '
keys { k[$1]=1; next }
!k[$1]
' keys=1 file2 keys=0 file1
To be honest, I'm not sure whether the variable assignment on the command line
or getline in a BEGIN block is more portable.
Have a nice day,
Berny
- replacement for 'join'?, Bruno Haible, 2021/04/04
- Re: replacement for 'join'?,
Bernhard Voelker <=
- Re: replacement for 'join'?, Bruno Haible, 2021/04/05
- Re: replacement for 'join'?, Paul Eggert, 2021/04/05
- Re: replacement for 'join'?, Bernhard Voelker, 2021/04/06
- Re: replacement for 'join'?, Paul Eggert, 2021/04/06
- Re: replacement for 'join'?, Bruno Haible, 2021/04/06
- Re: replacement for 'join'?, Bernhard Voelker, 2021/04/07
- Re: replacement for 'join'?, Bruno Haible, 2021/04/07