-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm trying to locate messages on a mail archive, looking for the
Message-ID header. It works, except on a 5% of the messages.
I have found these combinations:
Message-id
Message-ID
Message-Id
So the basic command is:
grepmail -h ^Message-[Ii][dD].*"$MSGID" ~/Mail/_Lists/_filed/os-en.2007*
which should find all those combinations. But no. My script doesn't find:
"f4sjvj$1p6$1@sea.gmane.org"
The problem is that Midnight Commander does find it in the expected file.
But not grepmail, nor grep.
cer@Telcontar:~/tmp/mailarchive> grepmail -h ^Message-[Ii][dD].*"f4sjvj$1p6$1@sea.gmane.org" ~/Mail/_Lists/_filed/os-en.200705..08
cer@Telcontar:~/tmp/mailarchive>
Or a shorter version:
cer@Telcontar:~/tmp/mailarchive> grepmail -h "f4sjvj$1p6$1@sea.gmane.org" ~/Mail/_Lists/_filed/os-en.200705..08
cer@Telcontar:~/tmp/mailarchive>
Not even plain grep:
cer@Telcontar:~/tmp/mailarchive> grep -i "f4sjvj$1p6$1@sea.gmane.org" ~/Mail/_Lists/_filed/os-en.200705..08
cer@Telcontar:~/tmp/mailarchive>
But MC finds it!
+++······························
home/cer/Mail/_Lists/_filed/os-en.200705..08 22237684/51M 41%
Subject: [opensuse] Re: SUSE 10.0: How to prevent mount of USB disk with subfs?
Date: Fri, 15 Jun 2007 01:45:54 +0200
Lines: 41
Message-ID:
Hello, On Mon, 05 Apr 2021, Carlos E. R. wrote:
grepmail -h ^Message-[Ii][dD].*"$MSGID" ~/Mail/_Lists/_filed/os-en.2007*
What can I do so that the $ inside the $MSGID content is passed to grepmail and not interpreted as a variable start? Do I need to do text substitution first inside $MSGID, replacing '$' with '\$'? Is there some other way?
$ grepmail -h "^Message-[Ii][Dd].*${MSGID//$/\\$}" \ ~/Mail/_Lists/_filed/os-en.2007* HTH, -dnh -- +#if defined(__alpha__) && defined(CONFIG_PCI) + /* + * The meaning of life, the universe, and everything. Plus + * this makes the year come out right. + */ + year -= 42; +#endif -- From the patch for 1.3.2: (kernel/time.c), submitted by Marcus Meissner
On 4/5/21 11:50 PM, Carlos E. R. wrote:
grep -i "f4sjvj$1p6$1@sea.gmane.org" ~/Mail/_Lists/_filed/os-en.200705..08 __________^__________________________"
1. As you have put the pattern in double quotes, the shell will try to expand the variables $1p6 and $1, and - as they're probably not defined - therefore pass the pattern 'f4sjvj@sea.gmane.org' to grep(1). --> use single quotes '' 2. As you pass something with a '$' in the pattern, but that is a special character matching the end of a line, you need to tell grep(1) to take the whole pattern as literal string: --> use the -F option. $ grep -Fi 'f4sjvj$1p6$1@sea.gmane.org' ~/Mail/_Lists/_filed/os-en.200705..08 Have a nice day, Berny
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday, 2021-04-06 at 01:00 +0200, Bernhard Voelker wrote:
On 4/5/21 11:50 PM, Carlos E. R. wrote:
grep -i "f4sjvj$1p6$1@sea.gmane.org" ~/Mail/_Lists/_filed/os-en.200705..08 __________^__________________________"
1. As you have put the pattern in double quotes, the shell will try to expand the variables $1p6 and $1, and - as they're probably not defined - therefore pass the pattern 'f4sjvj@sea.gmane.org' to grep(1). --> use single quotes ''
2. As you pass something with a '$' in the pattern, but that is a special character matching the end of a line, you need to tell grep(1) to take the whole pattern as literal string: --> use the -F option.
$ grep -Fi 'f4sjvj$1p6$1@sea.gmane.org' ~/Mail/_Lists/_filed/os-en.200705..08
Ah... Unfortunately, grepmail doesn't have that option, and I do have to use grepmail. grep -F, --fixed-strings Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by newlines, any of which is to be matched. grepmail -f Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. -F Force grepmail to process all files and streams as though they were mailboxes. (i.e. Skip checks for non-mailbox ASCII files or binary files that don't look like they are compressed using known schemes.) - -- Cheers, Carlos E. R. (from openSUSE 15.2 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- iHoEARECADoWIQQZEb51mJKK1KpcU/W1MxgcbY1H1QUCYGumLhwccm9iaW4ubGlz dGFzQHRlbGVmb25pY2EubmV0AAoJELUzGBxtjUfVQSkAnAteZncOx5ubDJIWhrET Pp7OIsvqAKCXMg8RWOfZDP0pwHmc1iLKNE3YNw== =1lFe -----END PGP SIGNATURE-----
participants (3)
-
Bernhard Voelker
-
Carlos E. R.
-
David Haller