Re: Tool to uncat file
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. > > Is there such a tool, or any other ideas? If I understand correctly you are looking for split(1). -p pattern The file is split whenever an input line matches pattern, which is interpreted as an extended regular expression. The matching line will be the first line of the next output file. This option is incompatible with the -b and -l options. -- Eitan Adler "Security is increased by designing for the way humans actually behave." -Jakob Nielsen ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Tool to uncat file
> > 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 ... > > csplit(1) csplit would cover the case where the input file is text, to be split on line boundaries based on patterns found within the lines; but the example given looks like a binary pattern and my reading of the inquiry is that the split should occur at the pattern rather than at a nearby newline. Grepping the ports INDEX for "split" yields the following candidates which might bear examination, to see if any of them will work: misc/granulate sysutils/gfslicer sysutils/hoz sysutils/lxsplit ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: Tool to uncat file
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? csplit(1) Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW signature.asc Description: OpenPGP digital signature
Re: Tool to uncat file
$ 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Tool to uncat file
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? -- Polytropon >From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"