From owner-freebsd-questions@FreeBSD.ORG Fri Sep 5 16:27:14 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 902C21065670 for ; Fri, 5 Sep 2008 16:27:14 +0000 (UTC) (envelope-from mkbucc@gmail.com) Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.28]) by mx1.freebsd.org (Postfix) with ESMTP id 475578FC15 for ; Fri, 5 Sep 2008 16:27:13 +0000 (UTC) (envelope-from mkbucc@gmail.com) Received: by yx-out-2324.google.com with SMTP id 8so296820yxb.13 for ; Fri, 05 Sep 2008 09:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=sW1B/qniiUfCchhjfrCoRfk8Y3Jhq+raN1onbZmudMo=; b=Qi5RtY4Fa64EtR0aJIbWqjqfeNWYb3MTxeBuF+N3U4GpsotIk+kC7dUFKzaX7XGwN6 0xedefwIUf22rKYlrCZX+XAZ2Cc+dfeKmHvX7noRJO0wbqSsPuWeulJRQjNB0gER6lHx BJxw5+Mybi3rZ+VX6zHdGMhCL2f+/84/pWkkk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=EuiIj4EPVV2EbW4JsZoupcoE9s3ZMe6HqaJfdmqOMpxbM06zh8I7Gce0vu7T1ZXzmd Jx0m48/cUVpzjpS8wbk+eCm4aNCPfK5iK/VmF6dW2iYBJqyguWIcXnlQqc/djUt423OI pQ88e3V044DpQb4qkzwvkAhhJ+lFqnhT2hwtw= Received: by 10.114.53.18 with SMTP id b18mr10267451waa.141.1220632032635; Fri, 05 Sep 2008 09:27:12 -0700 (PDT) Received: by 10.114.53.8 with HTTP; Fri, 5 Sep 2008 09:27:12 -0700 (PDT) Message-ID: <59f4cb420809050927w71fea733mcf7a2071c24cdc93@mail.gmail.com> Date: Fri, 5 Sep 2008 12:27:12 -0400 From: "Mark B." To: "Giorgos Keramidas" In-Reply-To: <87vdxa4p2p.fsf@kobe.laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <59f4cb420809050714i16ebe30bmd9f325592f05516e@mail.gmail.com> <87vdxa4p2p.fsf@kobe.laptop> Cc: freebsd-questions@freebsd.org Subject: Re: How to delete non-ASCII chars in file X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2008 16:27:14 -0000 On Fri, Sep 5, 2008 at 10:58 AM, Giorgos Keramidas wrote: > $ echo '^Fhello^F' | sed -e 's/[^[:print:]]*//' | hd > 00000000 68 65 6c 6c 6f 06 0a |hello..| > 00000007 > $ Thanks. > The matching pattern is wrong. You need `[^[:print:]]'. The character > class of printable characters is `[:print:]', and you can negate the > pattern with `[^xxxx]' where `xxxx' is the character class; hence the > extra pair of brackets in `[^[:print:]]'. In case you are interested, I've patched the re_format man page with this example. I had read it, and it says :print: is the "name of the character class." I think the concrete example helps clarify things. A follow question--is it possible to use that statement in a Makefile (BSD)? A straight cut 'n paste didn't work, and I couldn't figure out the escaping to make it work. Thanks, m cd to /usr/src/lib/libc/regex/ and apply this patch. --- /dev/null Fri Sep 5 12:12:21 2008 +++ re_format.7 Fri Sep 5 12:18:29 2008 @@ -288,6 +288,10 @@ A locale may provide others. A character class may not be used as an endpoint of a range. .Pp +To match all characters not in a class, use a bracket expression +like this: +.Ql [^[:print:]] . +.Pp There are two special cases\(dd of bracket expressions: the bracket expressions .Ql [[:<:]]