help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] unmatched


From: Patrick Hess
Subject: Re: [Help-bash] unmatched
Date: Mon, 5 Sep 2016 02:10:03 +0200
User-agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 04.09.2016 00:57, Val Krem wrote:
awk  'NR==FNR{c[$1]++;next};c[$2] >0' file1 file2

Is it possible to get the negative of this teh above line? i.e., to get the 
unmatched lines

There might be more elegant and/or readable solutions to this task,
but taking your awk script as a starting point, this should give
you the result you want:

    awk 'NR == FNR { c[$1]++; next }   \
         $1 ~ /^[0-9]+/ && c[$2] == 0' \
        file1 file2

"$1 ~ /^[0-9]+/" will get rid of file2's header, including the blank
line that follows it, and "c[$2] == 0" will be true for any number in
the second column of file2 that had not been inserted into the array
when processing file1.

Patrick

--
If you'd like to send me a private message, make sure to remove
the "_lists" part from my address.



reply via email to

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