From owner-freebsd-questions@FreeBSD.ORG Wed Jul 16 21:01:49 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA37037B401 for ; Wed, 16 Jul 2003 21:01:49 -0700 (PDT) Received: from mtaw4.prodigy.net (mtaw4.prodigy.net [64.164.98.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7673043FAF for ; Wed, 16 Jul 2003 21:01:49 -0700 (PDT) (envelope-from mbsd@pacbell.net) Received: from atlas (adsl-64-166-23-114.dsl.snfc21.pacbell.net [64.166.23.114]) by mtaw4.prodigy.net (8.12.9/8.12.3) with ESMTP id h6H411ru005865; Wed, 16 Jul 2003 21:01:16 -0700 (PDT) Date: Wed, 16 Jul 2003 21:00:41 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= X-X-Sender: mikko@atlas.home To: BSD baby In-Reply-To: <20030717004419.GA91784@mail.hitmedia.com> Message-ID: <20030716205247.P489@atlas.home> References: <20030717004419.GA91784@mail.hitmedia.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-questions@freebsd.org Subject: Re: how to copy just part of a file? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2003 04:01:50 -0000 On Wed, 16 Jul 2003, BSD baby wrote: > Is there an easy built-in way to copy only part of a file? > > I want to take a WAV audio file and copy from #__ bytes to > #___ bytes into a new file. > > (I'm making 30-second clips of files.) Try "dd". Thus: dd bs=1 skip=$offset count=$length < infile > outfile It is possible that a block size of one byte is kind of inefficient, so if you can operate in units of some larger size that might be good. For example "bs=1k". See "man dd". Also, remember that WAV files have a 44 byte (or was that 42...?) wav header. Yes, you can extract it with "dd bs=44 count=1", but I'm too lazy to find out whether you can just prepend it to any split files right now (i.e. if the file contains any length info; I suspect not). > Though I found a scripting way to do it with PHP, I'm wondering > if there's a more direct way to do it with basic GNU/BSD commands. Ever heard of POSIX... ;-) $.02, /Mikko