From owner-freebsd-questions@FreeBSD.ORG Sun Jan 14 03:42:31 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 65AB216A403 for ; Sun, 14 Jan 2007 03:42:31 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id BEF3013C489 for ; Sun, 14 Jan 2007 03:42:30 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (dialup190.ach.sch.gr [81.186.70.190]) (authenticated bits=128) by igloo.linux.gr (8.13.8/8.13.8/Debian-3) with ESMTP id l0E3fx5W012446 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 14 Jan 2007 05:42:10 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.13.8/8.13.8) with ESMTP id l0E3fopi003038; Sun, 14 Jan 2007 05:41:50 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.13.8/8.13.8/Submit) id l0E3fmNP003037; Sun, 14 Jan 2007 05:41:48 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Sun, 14 Jan 2007 05:41:48 +0200 From: Giorgos Keramidas To: Gary Kline Message-ID: <20070114034148.GC2734@kobe.laptop> References: <20070114024551.GA21847@thought.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070114024551.GA21847@thought.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.71, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.49, BAYES_00 -2.60, DNS_FROM_RFC_ABUSE 0.20) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-questions@freebsd.org Subject: Re: perl substitution question 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: Sun, 14 Jan 2007 03:42:31 -0000 On 2007-01-13 18:45, Gary Kline wrote: > Anybody know if I can do a perl substitution of the scads of > \x80\x9D to simple double-quotes (") from the command line? You already have part of the syntax right: ,---------------------------------------------------------------- | keramida@kobe:/home/keramida$ hd binary.dat | 00000000 80 68 65 6c 6c 6f 20 77 6f 72 6c 64 9d 0a |.hello world..| | 0000000e | keramida@kobe:/home/keramida$ perl -pe 's/\x80/"/; s/\x9d/"/;' < binary.dat | "hello world" | keramida@kobe:/home/keramida$ `---------------------------------------------------------------- Note how the file `binary.dat', which I edited with hexl-mode in Emacs, to insert the 0x80 and 0x9D hex values, gets converted to "hello world" on output.