From owner-freebsd-questions@freebsd.org Thu Dec 7 01:20:18 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 45FD5E93E64 for ; Thu, 7 Dec 2017 01:20:18 +0000 (UTC) (envelope-from yuripv@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.gmx.net", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A4C296CEA0 for ; Thu, 7 Dec 2017 01:20:17 +0000 (UTC) (envelope-from yuripv@gmx.com) Received: from thor.xvoid.org ([62.183.127.28]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LxPuE-1f7SOy2iDq-016uev; Thu, 07 Dec 2017 02:20:14 +0100 Subject: Re: grep problem To: RW , freebsd-questions@freebsd.org References: <20171207005542.43a7f55f@gumby.homeunix.com> From: Yuri Pankov Message-ID: <8277e864-c52a-09a4-dca9-58f83469f5fc@gmx.com> Date: Thu, 7 Dec 2017 04:20:13 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171207005542.43a7f55f@gumby.homeunix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:f915QFj4S5o58i7dRXSHj3mA4uShiTlnWK1op6TePcMCb5h3wVa fOswRSQLRPndLc8LpemfZpbnh2zeyqF8wbslG2Nt+FbbDxa1m5k8ydwh7s0YuwoFqXnZFq7 Trz3vKzBkYHLqqxazooFWwTAUtlLudsghXc3zxY5eBjISIIEM8Nprh0cx98fkAH/QgOTMuN teKqvZQziX4OnIweDPHGw== X-UI-Out-Filterresults: notjunk:1;V01:K0:fQiPtWvxj/w=:TugzIYuDLxmjB9FWRmWVKK ziJKab/N3TWFmq/aWh4IpBd+QPLpgL6IbCFKKsR8sRCFMPWxESx1Wj8xTvy+/b4Fy5glX/++K irKYkgB3LJeuq/h0UcGIrtg30S6H6BM8cqMLpU4fjLhaHLB0QcsUT2HXOLCObWUElQg0xZKwi ExZHUd+/F7iIIxjzidFNJRr+ZU4MSffUyv2Lo4rWBEmwvHNTOeDqgNJeDZz6fMYVjp7c8t0wR LhfAj6xTr9smj0gLH5pJS4ot885I1GCRdb2z+2SS71+nCBy7KgYnw7uFeDNQtuYvYR44xr4k9 7MiMq0KrYhz2Yosn2AIt4NZFQMWiBGFYLUbWtyhHx+DH4ElWFR7avatCJIj7a5vFPj7/lpJb1 byPIXd6u+F11tuCUAS4vh8ecJkmRVSpYJ8hvIkbNQoa/PJIiwnsbBiZPZNEqwOqhn3Wm7F+PS 4QyHtIdgFQmP17u9LdDSUVq5rHCEaNZmBcE7tgVoP/fUns+VwDxyHoWq6UrSxzkY7ApjTjhGl eqm+WNC612iXJUSdLP0phg4SWp60hDwcOaGUDCxclgEAsGb0lHcbUXg3251yyVzwcDHLdxHKW DL4j/P/PDou95OZ3GGjx/mzw8Sx5R94o1VA8CRNOXxdCKXvhOucKXabRhXmatAIhCfm6Id+0V Mc0TX+We+d9Q8HgzbKupRFGSK0Qju5BTd4USFHvf+WqjF3ca8Ef94aRGLSf92oE8EDUzzOfHR lVXI47AdzP0y+t9Bbxegxa37zNuZPULybgx3upFmlG0h3dv+pqt5iGPyItS2CDPtB6jmxzGbx vCWa19KLb/fTIMoC+VYGjdggZRtU56RddiwZjksf+eLky2nA7KFH7wMC2YCdyqBMdDaQYOT 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 01:20:18 -0000 On Thu, Dec 7, 2017 at 00:55:42AM +0000, RW via freebsd-questions wrote: > > Can anyone explain why '-' needs escaping in the following. What > special meaning does it have outside of []? > > $ echo 'a-b' | grep 'a-b' > a-b > > $ echo 'a-b' | grep '-b' > Usage: grep [OPTION]... PATTERN [FILE]... > Try `grep --help' for more information. > > $ 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