From owner-freebsd-questions@freebsd.org Thu Dec 7 01:09:14 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 8CCD2E9325C for ; Thu, 7 Dec 2017 01:09:14 +0000 (UTC) (envelope-from zarniwhoop@ntlworld.com) Received: from know-smtprelay-omc-5.server.virginmedia.net (know-smtprelay-omc-5.server.virginmedia.net [80.0.253.69]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client CN "Bizanga Labs SMTP Client Certificate", Issuer "Bizanga Labs CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 025EA6C4FF for ; Thu, 7 Dec 2017 01:09:13 +0000 (UTC) (envelope-from zarniwhoop@ntlworld.com) Received: from localhost.localdomain ([81.97.232.230]) by know-smtprelay-5-imp with bizsmtp id ip811w0084yv82R01p81Qr; Thu, 07 Dec 2017 01:08:01 +0000 X-Originating-IP: [81.97.232.230] X-Authenticated-User: X-Spam: 0 X-Authority: v=2.1 cv=Ku2wojiN c=1 sm=1 tr=0 a=obylDaYnIsVqxbenyIBF4Q==:117 a=obylDaYnIsVqxbenyIBF4Q==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=x7bEGLp0ZPQA:10 a=ocR9PWop10UA:10 a=I7TncRzG1z4wEcU5MS4A:9 a=QEXdDO2ut3YA:10 Received: by localhost.localdomain (Postfix, from userid 1000) id 2075341B8C; Thu, 7 Dec 2017 01:08:01 +0000 (GMT) Date: Thu, 7 Dec 2017 01:08:01 +0000 From: Ken Moffat To: RW Cc: freebsd-questions@freebsd.org Subject: Re: grep problem Message-ID: <20171207010801.GA10604@milliways.localdomain> References: <20171207005542.43a7f55f@gumby.homeunix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett Content-Transfer-Encoding: 8bit In-Reply-To: <20171207005542.43a7f55f@gumby.homeunix.com> User-Agent: Mutt/1.9.1 (2017-09-22) 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:09:14 -0000 On Thu, Dec 07, 2017 at 12: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 > In gnu grep, '-' indicates it should read from STDIN, I assume that FreeBSD's grep is the same. ĸen -- Truth, in front of her huge walk-in wardrobe, selected black leather boots with stiletto heels for such a barefaced truth. - Unseen Academicals