bug-grep
[Top][All Lists]
Advanced

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

bug#36764: grep -q throwing up No such file or directory error


From: Lewis Farnworth
Subject: bug#36764: grep -q throwing up No such file or directory error
Date: Mon, 22 Jul 2019 18:12:10 +0100

Hello,

Never posted a bug report before but I'm certain that the -q flag for grep
is broken.

I previously had a working script, that used -q in this context here:

if grep -q "RewriteCond %{HTTP_REFERER} !.*example.com*" $line; then

-----------------------------------------------------------------------------------------------------
That syntax was perfectly functioning as a conditional inside of a while
loop, to detect a colleague's error inside of a bunch of .htaccess rules.

I ran it and got what I wanted to work.

That was a few weeks back, since then I have ran a yum update (on CentOS 7)
and tried to adopt the same flag in a different script... To no avail.

This time, I'm trying to basically ascertain which servers on a given
domain are using Gmail. I've ran some dig, grep, sed & awk to ascertain a
list of mail servers the domain is using. One of the outputs which I'm
looking for looks something like this:

$   echo $mailServ:
alt3.aspmx.l.google.com.
alt4.aspmx.l.google.com.
alt1.aspmx.l.google.com.
alt2.aspmx.l.google.com.
aspmx.l.google.com.

*The script I'm running:*

if grep -q "google.com" $mailServ; then
printf "%s uses google for mail \n" $mailServ
fi

I've run into a few weird error messages when trying to use the -q
option... And I'm 100% certain that this is not a syntax issue (but there's
a part of me wishing it is).

*The error I get is: *

grep: aspmx.l.google.com.: No such file or directory
grep: alt1.aspmx.l.google.com.: No such file or directory
grep: alt4.aspmx.l.google.com.: No such file or directory
grep: alt2.aspmx.l.google.com.: No such file or directory
grep: alt3.aspmx.l.google.com.: No such file or directory

When in actual fact, all I need is the  printf command output. I tried to
run the exact same script on Debian 9, to ensure that was not the issue...
Apparently that doesn't work either.

I ran an individual grep command (no flags) on text file with the exact
same contents.
It came back with positives, as you'd expect... as every line had the word
google in there.

I tried to use the first script I wrote again, for the sake of a sanity
check, and that script is now broken too.

To reiterate:

if grep -q "thing_i'm_looking_for" $variable_i'm_looking_in; then

doesn't work, on CentOS 7 or Debian 9.  I have tried putting the variable
in single and double quotes, putting the thing I'm looking for in single
and double quotes, putting the if parameters inside square brackets,
exporting the variable to a text file and grepping from that and using the
-s flag... Please can someone take a look and check that I'm not insane and
that this infact a bug and not my own problem.

GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)

Kind regards,
Lewis


reply via email to

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