From owner-freebsd-questions@FreeBSD.ORG Tue Oct 19 13:49:24 2010 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 42FA01065698 for ; Tue, 19 Oct 2010 13:49:24 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from ms16-1.1blu.de (ms16-1.1blu.de [89.202.0.34]) by mx1.freebsd.org (Postfix) with ESMTP id F1DFC8FC1B for ; Tue, 19 Oct 2010 13:49:23 +0000 (UTC) Received: from [193.31.11.193] (helo=current.Sisis.de) by ms16-1.1blu.de with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1P8CZ7-0005CM-Jx; Tue, 19 Oct 2010 15:49:21 +0200 Received: from current.Sisis.de (current [127.0.0.1]) by current.Sisis.de (8.14.3/8.14.3) with ESMTP id o9JDnOqh004149; Tue, 19 Oct 2010 15:49:24 +0200 (CEST) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by current.Sisis.de (8.14.3/8.14.3/Submit) id o9JDnO7i004148; Tue, 19 Oct 2010 15:49:24 +0200 (CEST) (envelope-from guru@unixarea.de) X-Authentication-Warning: current.Sisis.de: guru set sender to guru@unixarea.de using -f Date: Tue, 19 Oct 2010 15:49:24 +0200 From: Matthias Apitz To: andrew clarke Message-ID: <20101019134924.GA4076@current.Sisis.de> References: <20101019130845.GA3773@current.Sisis.de> <20101019133644.GA70489@ozzmosis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20101019133644.GA70489@ozzmosis.com> X-Operating-System: FreeBSD 8.0-CURRENT (i386) User-Agent: Mutt/1.5.19 (2009-01-05) X-Con-Id: 51246 X-Originating-IP: 193.31.11.193 Cc: freebsd-questions@freebsd.org Subject: Re: filter a binary file and reduce 0x150a to 0x15 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Matthias Apitz List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2010 13:49:24 -0000 El día Wednesday, October 20, 2010 a las 12:36:44AM +1100, andrew clarke escribió: > I'd be personally more comfortable doing it in C or Python but I think > you can do this with tr -s. me too; > > Note: 0x15 == 25 octal; 0x0a == 12 octal. I don't recall if it's > possible to use hex values in csh arguments - if so, what is the > syntax? > > 0:28 ozzmosis@blizzard [~/tmp]printf 'Hello\25\12world.\12' > blah > > 0:28 ozzmosis@blizzard [~/tmp]hd blah > 00000000 48 65 6c 6c 6f 15 0a 77 6f 72 6c 64 2e 0a |Hello..world..| > 0000000e > > 0:28 ozzmosis@blizzard [~/tmp]tr -s '\25\12' '\25' < blah | hd > 00000000 48 65 6c 6c 6f 15 77 6f 72 6c 64 2e 15 |Hello.world..| > 0000000d I saw this, but this has the side affect to reduce any occourance of a duouble 0x1515 to 0x15: guru@current:~> printf '\25\25Hello\25\12world.\12' > blah guru@current:~> hd blah 00000000 15 15 48 65 6c 6c 6f 15 0a 77 6f 72 6c 64 2e 0a |..Hello..world..| 00000010 guru@current:~> tr -s '\25\12' '\25' < blah | hd 00000000 15 48 65 6c 6c 6f 15 77 6f 72 6c 64 2e 15 |.Hello.world..| Thanks anyway matthias -- Matthias Apitz t +49-89-61308 351 - f +49-89-61308 399 - m +49-170-4527211 e - w http://www.unixarea.de/