From owner-freebsd-questions@FreeBSD.ORG Tue Oct 19 14:04:52 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 D73FB106566B for ; Tue, 19 Oct 2010 14:04:52 +0000 (UTC) (envelope-from mail@ozzmosis.com) Received: from outbound.icp-qv1-irony-out1.iinet.net.au (outbound.icp-qv1-irony-out1.iinet.net.au [203.59.1.106]) by mx1.freebsd.org (Postfix) with ESMTP id 45B848FC12 for ; Tue, 19 Oct 2010 14:04:51 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEABc8vUx8lIZo/2dsb2JhbAChaHG9aoVKBI1FIA X-IronPort-AV: E=Sophos;i="4.57,350,1283702400"; d="scan'208";a="724256606" Received: from unknown (HELO smtp.phoenix) ([124.148.134.104]) by outbound.icp-qv1-irony-out1.iinet.net.au with ESMTP; 19 Oct 2010 21:36:44 +0800 Received: by smtp.phoenix (Postfix, from userid 1001) id 129911727A; Wed, 20 Oct 2010 00:36:44 +1100 (EST) Date: Wed, 20 Oct 2010 00:36:44 +1100 From: andrew clarke To: Matthias Apitz Message-ID: <20101019133644.GA70489@ozzmosis.com> References: <20101019130845.GA3773@current.Sisis.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101019130845.GA3773@current.Sisis.de> User-Agent: Mutt/1.5.21 (2010-09-15) 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2010 14:04:52 -0000 On Tue 2010-10-19 15:08:45 UTC+0200, Matthias Apitz (guru@unixarea.de) wrote: > Before I programm it in C (or whatever), is there any normal shell tool > to filter a (large) binary file and change any occurance of 0x150a to > 0x15 (i.e. delete \n but only if it follows a char 0x15)? I'd be personally more comfortable doing it in C or Python but I think you can do this with tr -s. 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 Regards Andrew