bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replacement for 'join'?


From: Bruno Haible
Subject: Re: replacement for 'join'?
Date: Tue, 06 Apr 2021 03:01:56 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-206-generic; KDE/5.18.0; x86_64; ; )

Hi Berny,

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

Wonderful! Thank you. Both solutions work fine with the 'awk' on Alpine Linux
(BusyBox v1.32.1).

> To be honest, I'm not sure whether the variable assignment on the command line
> or getline in a BEGIN block is more portable.

As Alpine Linux is the only platform that lacks 'join', awk portability is
not an issue (so far).

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]