From owner-freebsd-questions@freebsd.org Mon Sep 28 13:07:56 2015 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 80A68A0B8B8 for ; Mon, 28 Sep 2015 13:07:56 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (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 25FD11D80 for ; Mon, 28 Sep 2015 13:07:56 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: by wiclk2 with SMTP id lk2so100556919wic.1 for ; Mon, 28 Sep 2015 06:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=VGztbzfWbW2b25lGMLWz+/SyCEVFvz9Vg2CFxJba5fQ=; b=EhNmWWDvbvts5jeVGNN6xDzPqJs7pLtV70jlkG0u//iwYjrjO6eZnCOl8hQNtNScxu YeU1vaP1pJIt4YDQEkzFZB1pXEHrvaJoXtFCA6dP/Gg0zCvw5+BMZMG1YUFtU1sQmH9g W8d5yw5qWO9cGAfcMqRdwfkpI1WPPpXq//UCB3mOp1moCgAQCr+Hf89p5b8xbvblQAIy 9PvqUFKxTAfwcvEjK2PVGw55pwndaJ+gWvpH7qg+dnrFgB+eWB7Ae7dHatNQMscVY96b Yth/zfGSpM6k363hXN+we6p1h0/Ihr1ZHJe50/RMkF3a04RW/bg23rNO/zB92TcHfnJx Rvfg== X-Received: by 10.180.92.201 with SMTP id co9mr225250wib.58.1443445674559; Mon, 28 Sep 2015 06:07:54 -0700 (PDT) Received: from gumby.homeunix.com ([90.195.198.255]) by smtp.gmail.com with ESMTPSA id x7sm18275677wia.5.2015.09.28.06.07.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Sep 2015 06:07:53 -0700 (PDT) Date: Mon, 28 Sep 2015 14:07:52 +0100 From: RW To: freebsd-questions@freebsd.org Subject: Re: 10.2-RELEASE/amd64: grep regex syntax vs. grep-bug Message-ID: <20150928140752.0c182f1e@gumby.homeunix.com> In-Reply-To: <00e801d0f9e2$125ec430$371c4c90$@mgedv.net> References: <00e801d0f9e2$125ec430$371c4c90$@mgedv.net> X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; amd64-portbld-freebsd10.2) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Sep 2015 13:07:56 -0000 On Mon, 28 Sep 2015 13:37:35 +0200 no@spam@mgEDV.net wrote: > hi folks, > the goal: grep, that a variable contains a number and JUST digits. > # setup sample variable - we're on /bin/sh @ 10.2-RELEASE/amd64. > x="" > # od output the content of the variable to ensure content > echo "$x" | od -ctdC > 0000000 \n > 10 > 0000001 > # now try /usr/bin/grep'pin (C locale) that it contains... > # ^ at BOL... > # [0-9] require a digit > # * ... and digits following You're confusing + and *. [0-9]* matches any number of digits including zero [0-9]+ matches one or more digits. > # $ ...until we reach EOL > # ... but...: > echo "$x" | grep -c '^[0-9]*$' > 1 <== WHY?