Date: Wed, 16 Jul 2003 21:00:41 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net> To: BSD baby <bsdlap@hitmedia.com> Cc: freebsd-questions@freebsd.org Subject: Re: how to copy just part of a file? Message-ID: <20030716205247.P489@atlas.home> In-Reply-To: <20030717004419.GA91784@mail.hitmedia.com> References: <20030717004419.GA91784@mail.hitmedia.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030716205247.P489>
