From unknown Sun Jun 15 08:57:02 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36764: grep -q throwing up No such file or directory error Resent-From: Lewis Farnworth Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Mon, 22 Jul 2019 17:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36764 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: 36764@debbugs.gnu.org X-Debbugs-Original-To: bug-grep@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.156381800020923 (code B ref -1); Mon, 22 Jul 2019 17:54:02 +0000 Received: (at submit) by debbugs.gnu.org; 22 Jul 2019 17:53:20 +0000 Received: from localhost ([127.0.0.1]:33598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpcUw-0005RL-Te for submit@debbugs.gnu.org; Mon, 22 Jul 2019 13:53:19 -0400 Received: from lists.gnu.org ([209.51.188.17]:53960) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpbrN-00046p-ME for submit@debbugs.gnu.org; Mon, 22 Jul 2019 13:12:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47476) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hpbrM-0006H7-8R for bug-grep@gnu.org; Mon, 22 Jul 2019 13:12:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=BAYES_50, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hpbrK-0003Q7-RN for bug-grep@gnu.org; Mon, 22 Jul 2019 13:12:24 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:34606) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hpbrK-0003PW-L3 for bug-grep@gnu.org; Mon, 22 Jul 2019 13:12:22 -0400 Received: by mail-ot1-x341.google.com with SMTP id n5so41047352otk.1 for ; Mon, 22 Jul 2019 10:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=snFg1jqZEusfHuWY3FyBpqtLI5GbLhGl88/NJV28HK4=; b=Lj8fNIoI1HsdQtKz6Sat3QEgqJEFRrbdE9o2rY2EvuujvW25ojDz4OhOm04AriB/4x QkpboSXYHJC94UwbquKLth+OFYbQBMswwmZ1V07mtugwRBsrUh5kIsgi5drUspXf/CGQ R6WolK0hbN1nd2vtvGtbaMj4ZbLhld1DTqzP/hL7DF+adOlNlxl60U7+4Tl/JLqOT8aE 2wRkM+a60gpkxr8KNRKrYCXdw/l+GbC5TEwNkueBUfEyuuMPNNrmm730/2ER7qJG4l+I r0RO+PQh/nzYk4n3HmO20ea3nhzYPSJZ8PYXgMUKiJGZIOr7TBLCH67nCj8jlCd33wlc BQ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=snFg1jqZEusfHuWY3FyBpqtLI5GbLhGl88/NJV28HK4=; b=fAInSxIV7FeuEZ+sR/Za0WdKyYWk4On2IEU5rrTDVFj98zH4t1pznIaTs7tCmzZxM9 jGifc4Rz3GYvBGwBg5yWrWgwuuhYiA4YhAoTJDytgfSlocViLuOARvxfsE2I+MmP/wRs FSRX4rB1QyPpVpaYxpd/Mkuia9mcCejOZDDgovguzqgkYCKZopqTt6hLz3B8YaUuwsN/ vwNGfEU04xJSKYmE+Hp4VmweH1Ra7p6gBbqKV6xrelTrEcyzW94cphTns5b2/MolVgbZ CH48kwxiShItsAfb91gSSQiXi3OQQgGYqPsMItY3VqRvE2P9d1G2BUf/dieUpfsL6nMs TITw== X-Gm-Message-State: APjAAAXHBlZ/e0mldO6DaaNiTPyFpE9BJ3llzr5ah/Kb2JsFvhQV9vRK TtyxWMtMyyowW1GKe+SpehqRFYO0y9Mx/ahwdu3+bz7g X-Google-Smtp-Source: APXvYqzWihq1KsBQ83HXtEEhuBdwM0EUfBNp+ULuMAFdQC70vt4h2OZVMl+/LHJqmQy100MLQn63xLBRMg0pgWSWnus= X-Received: by 2002:a9d:7352:: with SMTP id l18mr48659278otk.292.1563815541218; Mon, 22 Jul 2019 10:12:21 -0700 (PDT) MIME-Version: 1.0 From: Lewis Farnworth Date: Mon, 22 Jul 2019 18:12:10 +0100 Message-ID: Content-Type: multipart/alternative; boundary="000000000000d4204d058e482db2" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::341 X-Spam-Score: -1.1 (-) X-Mailman-Approved-At: Mon, 22 Jul 2019 13:53:18 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) --000000000000d4204d058e482db2 Content-Type: text/plain; charset="UTF-8" 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 --000000000000d4204d058e482db2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 her= e:

if grep -q "RewriteCond %{HTTP_REFERER} !.= *example.com*" $line; then
=
------------------------------------------------------------= -----------------------------------------
That syntax was perfect= ly functioning as a conditional inside of a while loop, to detect a colleag= ue's error inside of a bunch of .htaccess rules.

I ran it and got what I wanted to work.=C2=A0

T= hat 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.=C2= =A0

This time, I'm trying to basically a= scertain 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 t= his:

$=C2=A0 =C2=A0echo $mailServ:
<= br>
The script I'm running:

<= /div>
if grep -q "google.com&quo= t; $mailServ; then
printf "%s uses google for mail \n" $mailSe= rv
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).=C2= =A0

The error I get is:=C2=A0
<= div>
grep: aspmx.l.goog= le.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 su= ch file or directory

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

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

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

To reiterate:
=
if grep -q "thing_i'm_looking_for" $variable_i= 'm_looking_in; then

doesn't work, on CentO= S 7 or Debian 9.=C2=A0 I have tried putting the variable in single and doub= le quotes, putting the thing I'm looking for in single and double quote= s, 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.=C2=A0

GNU bash, vers= ion 4.2.46(2)-release (x86_64-redhat-linux-gnu)

Kind regards,
Lewis=C2=A0






--000000000000d4204d058e482db2-- From unknown Sun Jun 15 08:57:02 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36764: grep -q throwing up No such file or directory error Resent-From: Assaf Gordon Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Mon, 22 Jul 2019 22:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36764 X-GNU-PR-Package: grep X-GNU-PR-Keywords: To: Lewis Farnworth Cc: 36764@debbugs.gnu.org Received: via spool by 36764-submit@debbugs.gnu.org id=B36764.156383381420279 (code B ref 36764); Mon, 22 Jul 2019 22:17:02 +0000 Received: (at 36764) by debbugs.gnu.org; 22 Jul 2019 22:16:54 +0000 Received: from localhost ([127.0.0.1]:33724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpgc1-0005H0-MC for submit@debbugs.gnu.org; Mon, 22 Jul 2019 18:16:54 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hpgc0-0005Gj-9T; Mon, 22 Jul 2019 18:16:52 -0400 Received: by mail-pg1-f193.google.com with SMTP id f5so9495985pgu.5; Mon, 22 Jul 2019 15:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WBJe088eig1sRHxmM9Dhe3Ltr56Jud+B1nYgF/UYiUI=; b=lWddbBFzDlqn/7Ctxx70rO4MMcFb9ThYBLOvitQz7LbfgaYc5C92wR3OHP4Di6RrJV TqEsAI9pIn0668hOBH/qNXgu0xtjb/JPLbiL8LncdckyAkREJ/7gzy6xLTNHwAMvoc9A SjjV8axERKnWxR42HPj2VDXRR3mnuv3VAIi6Wu+FnWMRRk7gC/fVkUUMnQXmO+e82/TG 91ISX/eNpTYKjTTTIAMX4+wSKKetuDGQieyXAJ1xuUW4OGy4fKCiBi9mvPM7EZcP61Db es5lWd3OwKaXXRGRqWrmAdkPpYf2BpBOp06XEab9irJ5MtXHCTtn9G4Bq8ib3NP9vAj4 Z5/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WBJe088eig1sRHxmM9Dhe3Ltr56Jud+B1nYgF/UYiUI=; b=a3sSmLOJOU0EeAA13/pblzXhn3jwq3EZdsuWZzbzqnqbz3EK316ZodWHbGXj9fS1iB ntDBcy9minzMtWgL+wKubCHoS+lv2315wupcjJY0g5Xt7dqp6fuA2Pvi95Dp524+CUcS 3gwwDYgWdgPy6ZrK4SOP/qGzX1OoVOnMe+J5P+D5AjG/k1QzQs+1jYZTNUuGfFMx0Zkn UsChQW3cPkcrDRAcX4xmQxF54mBdvRztAes7by5HA/BarmPlarkmN9V3x5nDW5XUuwJ2 ddbXjMGB5PIv7SI9IcVqH/EL4Ahf77MMHa88KR/jq5gkRXRmOP+MHr7FsEBtv/suJ0hS xYsw== X-Gm-Message-State: APjAAAWTus3HKIM0GbVfkM2NN9aiU5G1JZVhpq/eCV4kI0r6c/5TKKvq hAAMspTTcaq2t34wiRt8nDbN1sYx X-Google-Smtp-Source: APXvYqw3u5RxlKqKMU+z7oJKI9UZ6cBoW7iiwDJ1XKIfVZUAEiZW6eLWVJd81Oiux8EHnDQbLj76yw== X-Received: by 2002:a62:6044:: with SMTP id u65mr2350104pfb.15.1563833805580; Mon, 22 Jul 2019 15:16:45 -0700 (PDT) Received: from tomato (moose.housegordon.com. [184.68.105.38]) by smtp.gmail.com with ESMTPSA id a3sm32811681pfc.70.2019.07.22.15.16.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 15:16:44 -0700 (PDT) Received: by tomato (Postfix, from userid 1000) id A267768218F; Mon, 22 Jul 2019 16:16:43 -0600 (MDT) Date: Mon, 22 Jul 2019 16:16:43 -0600 From: Assaf Gordon Message-ID: <20190722221643.GC2676@tomato.moose.housegordon.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tag 36764 notabug close 36764 stop Hello, (answering out-of-order) On Mon, Jul 22, 2019 at 06:12:10PM +0100, Lewis Farnworth wrote: > 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. This is incorrect usage, and has never worked with gnu grep. The correct usage is: grep -q "thing_i'm_looking_for" "FILE to look in" Or, to check the content of a variable, use: echo "$variable_i'm_looking_in" | grep -q "$thing_i'm_looking_for" or the more robust: printf "%s" "$variable_i'm_looking_in" | grep -q "$thing_i'm_looking_for" > 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. As for the above, I would guess that the "while" loop read a FILENAME into the variable $line (e.g. a path of an .htaccess file), and then grep would search for the pattern in that file. If you have access to the machine where the above works, add "echo LINE=$line" to print the content of the variable, and you'll see it contains a file name. > 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 This is expected, as explained above. > 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. Use something like: if echo "$mailServ" | grep -q "google.com"; then printf "%s uses google for mail \n" $mailServ fi Note that this operates on the entire content of "$mailServ" (all lines together), not line-by-line. > I tried to use the first script I wrote again, for the sake of a sanity > check, and that script is now broken too. If an unmodified script used to work on CentOS before an upgrade, and stops working after the upgrade (again, unmodified), and you've isolated the issue to grep, please provide more details (e.g. the entire script). As such, I'm closing this as "not a bug", but discussion can continue by replying to this thread. regards, - assaf P.S. Note that in your regex patterns you use "." as a literal dot, but it is in fact a regex special character meaning "any character". So: grep "google.com" $FILE would also match a file containing "googleXcom". To match a literal dot, use "\.". From unknown Sun Jun 15 08:57:02 2025 X-Loop: help-debbugs@gnu.org Subject: bug#36764: grep -q throwing up No such file or directory error Resent-From: Stephane Chazelas Original-Sender: "Debbugs-submit" Resent-CC: bug-grep@gnu.org Resent-Date: Wed, 24 Jul 2019 06:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36764 X-GNU-PR-Package: grep X-GNU-PR-Keywords: notabug To: Assaf Gordon Cc: 36764@debbugs.gnu.org, Lewis Farnworth Received: via spool by 36764-submit@debbugs.gnu.org id=B36764.15639502036333 (code B ref 36764); Wed, 24 Jul 2019 06:37:02 +0000 Received: (at 36764) by debbugs.gnu.org; 24 Jul 2019 06:36:43 +0000 Received: from localhost ([127.0.0.1]:35924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hqAtH-0001e5-K7 for submit@debbugs.gnu.org; Wed, 24 Jul 2019 02:36:43 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50817) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hqAtF-0001dr-BM for 36764@debbugs.gnu.org; Wed, 24 Jul 2019 02:36:41 -0400 Received: by mail-wm1-f67.google.com with SMTP id v15so40660410wml.0 for <36764@debbugs.gnu.org>; Tue, 23 Jul 2019 23:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FHXkcb4NiUmiM1ctJ4hFwBh/H4nXmyBUFhkx340723Q=; b=JL7MjFru88DFRc3sQIc1CWXKQVKGxVPwObAeogfxIGlxrtfdV9IXjvTvFNy0jgVIs3 JnyRq8WoGmRCIEPi/YntfL0PJXfPp8wbjKnNIm7g8Rc5eWesa2xgkDU8hTCwhvpl9x3D 3W9DHxGC+OzcYg0ecrd+qLcB5ik4W/ff94GrBHKULsNY7GMvE7AfQial1etLqdaMvSaf dcUxJEIZYrCWBXLBSu9zNTbw+Uvlfc7sifueShR2ck/7Az0XFEtBNG1mO2iN9Ydd+3va 31GhLYD8fCHXnlNkmaVS2kAwlOTZkH5qDNsIur/eAAlrYP+16ZxpzpfDup8Aqv8wTSww hPmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FHXkcb4NiUmiM1ctJ4hFwBh/H4nXmyBUFhkx340723Q=; b=XsQIJuTJGI0bKEoh73Xp837BwHG2QGw0d40J1x29Id8eK4KGpyCjlTt5WbMgf2InTH rTGrvxZkk1NooEEPKswxbPPfH03qNDeqK/OAWSZdBw9I6IdIFFXXSecHMQeiJzO+GmYW MtAkOy1q77mzwoSUzA7oXARuNaDQJ0XfI4zNnRYQQcj7ORCx6KAfuv/RJMTr5Jm/BIhX pH3deNPJaYdOS6s5HM3mWbe8+tnUxoOTNY/zrSJ5HAHc/d8lJck8iS5NlmkTzM7sN7iM Oma+Vay5Ga2k87Qw+ZhNs7I/v76RNRHXcdqQOo9assnCok1VSk9R9X2Qc1oQzmj1XIN4 G+vg== X-Gm-Message-State: APjAAAVAl03IfPR7FH+dl+byBucNwcE3wT2WJp/cnzYK1dDh/mlmBFQP hEZXN/NHntbtbf5o8jDAsi0= X-Google-Smtp-Source: APXvYqzQQGLBe6N/l5H3W4QxPbI93x79fzUdfKH5iWYNhTrp7qFvaFP0uJq62SgZ5BdvXBHTB2y5gQ== X-Received: by 2002:a1c:be19:: with SMTP id o25mr69157449wmf.54.1563950195359; Tue, 23 Jul 2019 23:36:35 -0700 (PDT) Received: from chaz.gmail.com ([2.121.5.216]) by smtp.gmail.com with ESMTPSA id n14sm82387760wra.75.2019.07.23.23.36.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2019 23:36:34 -0700 (PDT) Date: Wed, 24 Jul 2019 07:36:32 +0100 From: Stephane Chazelas Message-ID: <20190724063632.jnqkvgalmi4kca47@chaz.gmail.com> References: <20190722221643.GC2676@tomato.moose.housegordon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190722221643.GC2676@tomato.moose.housegordon.com> User-Agent: NeoMutt/20171215 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 2019-07-22 16:16:43 -0600, Assaf Gordon: [...] > or the more robust: > > printf "%s" "$variable_i'm_looking_in" | grep -q "$thing_i'm_looking_for" [...] Preferably (POSIXly): printf "%s\n" "$variable_i'm_looking_in" | grep -qe "$thing_i'm_looking_for" Or printf "%s\n" "$variable_i'm_looking_in" | grep -q -- "$thing_i'm_looking_for" That is add a newline character so grep's input is valid text and guard against "$thing_i'm_looking_for" starting with -. [...] > Use something like: > > if echo "$mailServ" | grep -q "google.com"; then > printf "%s uses google for mail \n" $mailServ > fi [...] Note that it matches on googleXcom as well as "." is a regexp operator (I see you made that note later one). Use grep -q 'google\.com' or grep -Fq google.com, but better here would be to use a case statement and drop grep altogether: case $mailServ in (*google.com*) printf '%s uses google for mail\n' "$mailServ" esac -- Stephane