emacs-bug-tracker
[Top][All Lists]
Advanced

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

bug#63962: closed (possible error in the grep program)


From: GNU bug Tracking System
Subject: bug#63962: closed (possible error in the grep program)
Date: Thu, 08 Jun 2023 21:08:02 +0000

Your message dated Thu, 8 Jun 2023 14:07:16 -0700
with message-id <3c1dc8f7-6808-85ab-c27f-4738aa718068@cs.ucla.edu>
and subject line Re: bug#63962: possible error in the grep program
has caused the debbugs.gnu.org bug report #63962,
regarding possible error in the grep program
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
63962: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63962
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: possible error in the grep program Date: Thu, 8 Jun 2023 14:27:49 +0300
Hello,

in my work, I encountered a possible error in the grep program.
$ grep -V
grep (GNU grep) 3.4

1) The initial list of IP addresses in the file is formed start_list.txt .

2) Must be removed from the list start_list.txt IP addresses using a
larger file exclude_list.txt

grep -vF --file=exclude_list.txt start_list.txt > list_grep.txt

3) But after a series of checks, it turned out that grep "loses" 3 IP addresses
10.0.23.48
10.0.27.40
10.0.38.43

4) A bash script was written that solves the same problem in a different way

#!/bin/bash

:> list_while.txt
while read l
do
    if ! grep -m 1 -q "$l" exclude_list.txt; then
        echo ${l} >> list_while.txt
    fi
done < start_list.txt

5) The diff program has confirmed that there is indeed a difference in
the results

$ diff list_grep.txt list_while.txt
22a23
> 10.0.23.48
24a26
> 10.0.27.40
28a31
> 10.0.38.43

-- 
Best regards,
Vasilisc

Attachment: bug_grep.tar.gz
Description: GNU Zip compressed data


--- End Message ---
--- Begin Message --- Subject: Re: bug#63962: possible error in the grep program Date: Thu, 8 Jun 2023 14:07:16 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0
On 6/8/23 04:27, Василий Алексеенко wrote:

1) The initial list of IP addresses in the file is formed start_list.txt .

2) Must be removed from the list start_list.txt IP addresses using a
larger file exclude_list.txt

grep -vF --file=exclude_list.txt start_list.txt > list_grep.txt

The line '10.0.23.4' in exclude_list.txt matches the line '10.0.23.48' in start_list.text. That is, the first line is a substring of the second line. So this usage of 'grep' doesn't do what you want.

To get the effect you want, also use the -x option. E.g.:

grep -vxF -f exclude_list.txt start_list.txt


--- End Message ---

reply via email to

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