From owner-freebsd-questions@FreeBSD.ORG Wed Oct 20 01:49:22 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 9F2B41065670 for ; Wed, 20 Oct 2010 01:49:22 +0000 (UTC) (envelope-from vogelke@hcst.net) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 66A528FC15 for ; Wed, 20 Oct 2010 01:49:21 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o9K1nLID031376 for ; Tue, 19 Oct 2010 21:49:21 -0400 Received: (from vogelke@localhost) by beta.hcst.com (8.14.3/8.14.3/Submit) id o9K1nKtS031375; Tue, 19 Oct 2010 21:49:20 -0400 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 938F5BF78; Tue, 19 Oct 2010 21:21:00 -0400 (EDT) To: freebsd-questions@freebsd.org In-reply-to: <20101019130845.GA3773@current.Sisis.de> (message from Matthias Apitz on Tue, 19 Oct 2010 15:08:45 +0200) Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <20101019130845.GA3773@current.Sisis.de> Message-Id: <20101020012100.938F5BF78@kev.msw.wpafb.af.mil> Date: Tue, 19 Oct 2010 21:21:00 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) 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: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Oct 2010 01:49:22 -0000 >> On Tue, 19 Oct 2010 15:08:45 +0200, >> Matthias Apitz said: M> Before I programm it in C (or whatever), is there any normal shell tool M> to filter a (large) binary file and change any occurance of 0x150a to M> 0x15 (i.e. delete \n but only if it follows a char 0x15)? This seems to work, depending on your definition of normal: me% od -c blah 0000000 025 025 H e l l o 025 \n w o r l d . \n 0000020 me% perl -0pe 's/\025\n/\025/g;' < blah | od -c 0000000 025 025 H e l l o 025 w o r l d . \n 0000017 The "-0" says read null-terminated lines, so if your binary file is big enough and has few enough nulls, you could chew up a diaper-load of memory. -- Karl Vogel I don't speak for the USAF or my company A raccoon tangled with a 23,000 volt line today. The results blacked out 1400 homes and, of course, one raccoon. --Steel City News