help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] unmatched


From: Val Krem
Subject: Re: [Help-bash] unmatched
Date: Tue, 6 Sep 2016 02:40:21 +0000 (UTC)

Patrick, Dennis and all, 

Thank you so much for the help. Worked fine.




On Monday, September 5, 2016 8:34 AM, Patrick Hess <address@hidden> wrote:
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]