From owner-freebsd-questions@freebsd.org Thu Dec 7 05:57:21 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DAD1AE9E214 for ; Thu, 7 Dec 2017 05:57:21 +0000 (UTC) (envelope-from michaelsprivate@gmail.com) Received: from mail-qt0-x232.google.com (mail-qt0-x232.google.com [IPv6:2607:f8b0:400d:c0d::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 927EF77C5E for ; Thu, 7 Dec 2017 05:57:21 +0000 (UTC) (envelope-from michaelsprivate@gmail.com) Received: by mail-qt0-x232.google.com with SMTP id a16so14930956qtj.3 for ; Wed, 06 Dec 2017 21:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QjIT+GFVBGLojZe9qRyDdMpt/9+e2YdsgIr7CATIqlw=; b=UYovaf5Ft+lJ4Xbs1BzhbTUzN9Uwfw0yzh3H2PQ+OJzKbERO0sWI2BZ6lEuQOwY5XW fGaGtikk/4HTatbsgXmnhdfGTOyI5DPejwtAtPH6jqzdH1s+oCvA5WfUvuc7ktENdwd2 d3+iNj7m+zEtFL1xJ5/496msyxZUgNFlKI5CD55nG7DVIvaWPmsr1x+eEtIuWvX15zFO k8je+OOiV8Z3Az1kijy0/Ah1LYgdj2ZBD4Ktfpdyg7f3mPTPoCa4t7ZsfH52kFe/iLIz usQzayR8k3WxqAdehpOGfTn+P8OW6T0MdRKW1QqbAKyquXN8tBLyXgrdBsTyW3N6etec 88HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QjIT+GFVBGLojZe9qRyDdMpt/9+e2YdsgIr7CATIqlw=; b=gTq9dtopVO3ArImWm0RoSZvGJ5S0aNX5VLY6ZwhLQ3caN+XqjwB8xItfE3dsYlsKnj UcSRZ1nd6k/6XQBd661MIwiW7rHwhDY7ld2bqooNjDVi4ArYRskU5UD+dUDrBxyLFz8H k01ACDUWLCVW6BgnsuEOUvfZntMM1aPXDMCZiRc+IFJ7mlXzOxLqO6VAgpH9qAieYtZZ 2ETUybakr74Mt59uPYzyWhLLvj/kSD8Cnl6OQd++XeRoUJenO762fNbHsiiOnd4e9O1r isZoqKHQWOZYy+7VQGdOKYDpblsduXH2Euut6MkUCHyRWrXfpsJFUMgewIeYQPycYmA6 Otlw== X-Gm-Message-State: AKGB3mLAtB0Eiht0z9Dae+WKYqxLjA219LcKNFjTI4VkGQicout1YdY+ cyLl7+h1fGV93XUUVm8uT3ljEn7/Dlgq2zEScVo= X-Google-Smtp-Source: AGs4zMZdPcS2El7WqEIywx/lnpiuQX4+rgjG7xeUthdrRhplzt9zZm+3RUO363c/mSOoFe3Z3G7slCwoqU5RvRsgPXg= X-Received: by 10.200.26.13 with SMTP id v13mr8295019qtj.107.1512626240627; Wed, 06 Dec 2017 21:57:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.154.10 with HTTP; Wed, 6 Dec 2017 21:57:00 -0800 (PST) In-Reply-To: <20171207024717.15bf2287@planb.netng.org> References: <20171207005542.43a7f55f@gumby.homeunix.com> <8277e864-c52a-09a4-dca9-58f83469f5fc@gmx.com> <20171207024717.15bf2287@planb.netng.org> From: Michael Schuster Date: Thu, 7 Dec 2017 06:57:00 +0100 Message-ID: Subject: Re: grep problem To: Vladimir Botka Cc: Yuri Pankov , RW , freeBSD Mailing List Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Dec 2017 05:57:21 -0000 On Thu, Dec 7, 2017 at 2:49 AM, Vladimir Botka wrote: > > > $ echo 'a-b' | grep '\-b' > > > a-b > > > Looks like it's treated as option -b even inside the single quotes, you > > could use '--' to mark the end of options, i.e.: > > $ echo 'a-b' | grep -- -b > > a-b > > FWIW. Still the question remains what makes escaped -b a pattern. It'd > be necessary to learn about getopt_long which is used to parse the > arguments to understand it, I think. > I think it's much more straight-forward: single quotes cause \-b to be passed to grep, grep sees the "\" as escape and therefore *doesn't* read '-' as introducing an option, ergo -b must be a pattern to match. cheers Michael -- Michael Schuster http://recursiveramblings.wordpress.com/ recursion, n: see 'recursion'