From owner-freebsd-questions@FreeBSD.ORG Fri Dec 18 01:45:09 2009 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 E3CC610656A3 for ; Fri, 18 Dec 2009 01:45:09 +0000 (UTC) (envelope-from glarkin@FreeBSD.org) Received: from mail1.sourcehosting.net (113901-app1.sourcehosting.net [72.32.213.11]) by mx1.freebsd.org (Postfix) with ESMTP id BF87C8FC14 for ; Fri, 18 Dec 2009 01:45:09 +0000 (UTC) Received: from 68-189-245-235.dhcp.oxfr.ma.charter.com ([68.189.245.235] helo=cube.entropy.prv) by mail1.sourcehosting.net with esmtp (Exim 4.69 (FreeBSD)) (envelope-from ) id 1NLRtv-0002rm-KD; Thu, 17 Dec 2009 20:45:08 -0500 Received: from [127.0.0.1] (fireball.entropy.prv [192.168.1.12]) by cube.entropy.prv (Postfix) with ESMTP id 906BB38E59B7; Thu, 17 Dec 2009 20:45:03 -0500 (EST) Message-ID: <4B2ADE9E.6080707@FreeBSD.org> Date: Thu, 17 Dec 2009 20:45:02 -0500 From: Greg Larkin Organization: The FreeBSD Project User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Warren Block References: <20091218005102.GA51064@mech-cluster241.men.bris.ac.uk> In-Reply-To: X-Enigmail-Version: 0.96.0 OpenPGP: id=1C940290 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: 0.1 (/) Cc: Anton Shterenlikht , freebsd-questions@freebsd.org Subject: Re: editing a binary file X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: glarkin@FreeBSD.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2009 01:45:10 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Warren Block wrote: > On Fri, 18 Dec 2009, Anton Shterenlikht wrote: > >> I'm creating binary files in fortran. >> Fortran adds 4 byte record delimiters at the beginning >> and the end of each record, which, in the case of a binary >> file, is just at the beginning and at the end of the file. >> I need to delete these record delimiters, because the >> software I use to visualise the binary files interprets >> them as data. But I don't know how. I've looked at >> hexdump and od, but those are only dumping (I think) >> file contents, and I cannot see how to edit a file with them. > > truncate -4 myfile should get rid of the last four bytes. Maybe there's > a similar efficient way to truncate the start of a file. > > -Warren Block * Rapid City, South Dakota USA This should do it: dd if=oldfile of=newfile bs=1 skip=4 Hope that helps, Greg - -- Greg Larkin http://www.FreeBSD.org/ - The Power To Serve http://www.sourcehosting.net/ - Ready. Set. Code. http://twitter.com/sourcehosting/ - Follow me, follow you -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD8DBQFLKt6e0sRouByUApARAt0uAJ9CfG3DmsUbrUMg7hX2dIT+FOZ1sACfQtaD b7z5vvm/+vohelNIch1/ME8= =Zp5i -----END PGP SIGNATURE-----