From owner-freebsd-questions@FreeBSD.ORG Sun Feb 1 13:11:27 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 555BC106566B for ; Sun, 1 Feb 2009 13:11:27 +0000 (UTC) (envelope-from will.rutherdale@utoronto.ca) Received: from mail.vex.net (smaug.vex.net [208.76.104.132]) by mx1.freebsd.org (Postfix) with ESMTP id 2F0418FC18 for ; Sun, 1 Feb 2009 13:11:27 +0000 (UTC) (envelope-from will.rutherdale@utoronto.ca) Received: from [192.168.110.8] (unknown [207.35.13.130]) by mail.vex.net (Postfix) with ESMTPA id B8D00173D0 for ; Sun, 1 Feb 2009 08:11:25 -0500 (EST) Message-ID: <49859F76.3010707@utoronto.ca> Date: Sun, 01 Feb 2009 08:11:18 -0500 From: William Gordon Rutherdale User-Agent: Thunderbird 1.5.0.14ubu (X11/20080505) MIME-Version: 1.0 To: FreeBSD Questions References: <20090201140102.e9a9a41a.freebsd@edvax.de> In-Reply-To: <20090201140102.e9a9a41a.freebsd@edvax.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Tool to uncat file 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: Sun, 01 Feb 2009 13:11:27 -0000 $ man split This (split) is the standard unix utility to break a file up into pieces. It breaks it down either by a fixed number of lines or by a fixed number of bytes. Also the rules for dividing lines is simplistic: simple newline division, no special escape handling. If that doesn't suit your purpose, then you have to write your own custom split-like utility. I've done that in the past. For instance I once wrote a routine in Perl at work to divide Informix format .unl files (database dump), with special escape rules for newlines and special handling of binary data. For what you're describing you probably want to write a C program to do the job. -Will Polytropon wrote: > Dear list, > > before starting to code on my own, I'd like to ask if there's already a > tool to uncat files, defining the file separation position as a string > of bytes, usually given in hexadecimal form. > > An example could be this: > > % uncat -p 0x12,0x52,0xf1,0x09 file_orig > > It creates file_1 file_2 file_3. And, of course, > > % cat file_1 file_2 file_3 > file_orig > > would re-create the original file. The bytes 0x12,0x52,0xf1,0x09 tell the > file starting pattern (-p), where a new file begins. > > I cannot use dd due to the fact that the files concatenated are of a > different size. So the idea would be to look for specific byte pattern > and then start a new file each time it occurs on input. > > Is there such a tool, or any other ideas