From owner-freebsd-questions@freebsd.org Mon Sep 28 12:10: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 A81C9A0B28A for ; Mon, 28 Sep 2015 12:10:56 +0000 (UTC) (envelope-from nospam@mgedv.net) Received: from mail.mgedv.net (mail.mgedv.net [83.64.34.254]) by mx1.freebsd.org (Postfix) with ESMTP id 67AE81AED for ; Mon, 28 Sep 2015 12:10:55 +0000 (UTC) (envelope-from nospam@mgedv.net) Received: from my.loop (client.my.loop [255.255.255.255]) From: "no@spam@mgEDV.net" To: Subject: 10.2-RELEASE/amd64: grep regex syntax vs. grep-bug Date: Mon, 28 Sep 2015 13:37:35 +0200 Message-ID: <00e801d0f9e2$125ec430$371c4c90$@mgedv.net> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdD54LgS+P+ZaDglRtqWs3EfyB5y0g== Content-Language: de-at Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.20 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 12:10:56 -0000 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 # $ ...until we reach EOL # ... but...: echo "$x" | grep -c '^[0-9]*$' 1 <== WHY? it works if i remove the *, but this would only work for 1digit nrs. is this a grep bug or my false understanding of how '*' works?