Sponsored Content
Top Forums Shell Programming and Scripting Split a binary file into 2 basing on 2 delemiter string Post 302252614 by Averell on Thursday 30th of October 2008 12:51:39 AM
Old 10-30-2008
Java Split a binary file into 2 basing on 2 delemiter string

Hi all,

I have a binary file (orig.dat) and two special delimiter strings 'AAA' and 'BBB'. My binary file's content is as follow:
<Data1.1>AAA<Data1.2>BBB
<Data2.1>AAA<Data2.2>BBB
...
<DataN.1>AAA<DataN.2>BBB
DataX.Y might have any length, and contains any kind of special/printable characters.

Now I want to split this file into 2 files F1.dat and F2.dat, content of file 1 should be:
<Data1.1>
<Data2.1>
...
<DataN.1>

content of file 2 should be
<Data1.2>
<Data2.2>
...
<DataN.2>

Could you please help suggest me a way to do this.

Thank you very much!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace string in binary file

Dear all, How can replace special string with another string in binary file? Thanks&Best Regards (2 Replies)
Discussion started by: sg1207
2 Replies

2. Shell Programming and Scripting

Split a single file into several others basing on the last column

Hi folks, Happy new year. I have a file 'filename' that i wd like to split basing on the contents in the last column. The 'filename' content looks like 256772744788,9,11 256772744805,9,11 256772744792,9,11 256775543055,10,12 256782625357,9,12 256772368953,10,13 256772627735,10,13... (3 Replies)
Discussion started by: jerkesler
3 Replies

3. Shell Programming and Scripting

Split binary file with pattern

Hello! Have some problem with extract files from saved session. File contains any kind of special/printable characters. DATA NumberA DATA DATA Begin DATA1.1 DATA1.2 NumberB1 DATA1.3 DATA1.4 End DATA DATA DATA Begin DATA2.1 DATA2.2 NumberB2 DATA2.3 DATA2.4 End DATA DATA ... (4 Replies)
Discussion started by: vvild
4 Replies

4. UNIX for Advanced & Expert Users

Insert string in binary file at top

How can i append a EBCDIC string of 100 bytes to 0th position of a binary file in UNIX. (4 Replies)
Discussion started by: param_it
4 Replies

5. Shell Programming and Scripting

split a string and convert to binary

Hi All, Iam new to unix scripting and I want a split a string into 4 characters each, leaving the last two characters and convert the splitted values into binary. For example: string='ffd80012ffe20000ffebfffeffea0007fff0ffd70014fff1fff0fff0fff201' this should split as ffd8 0012 ffe2 . .... (5 Replies)
Discussion started by: srinivasayedla
5 Replies

6. Solaris

A string in a binary file

hi experts, anyone knows how can i find a string in a multiple binary files in a multiple directories and display the file name containing the string? i mean i have lots of folders with binary files and i am looking for specific string within one of these files i would like to know the right... (6 Replies)
Discussion started by: q8devilish
6 Replies

7. UNIX for Dummies Questions & Answers

Split binary file every occurrence of a group of characters

Hello I am new to scripts, codes, bash, terminal, etc. I apologize this my be very scattered because I frankly don't have any idea where to begin and I have had trouble sleeping lately. I have several 2GB files I wish to split. This Code 00 00 01 BA ** ** ** ** ** ** ** ** C3 F8 00 00 01 BB 00... (17 Replies)
Discussion started by: PatrickE
17 Replies

8. Shell Programming and Scripting

Pick a line in file 2 basing on array in file1

Dear friends, I have two files. One with all IDs(in a single field) . And another with data(of which say field 5 is ID). I want to create an array of IDs using first file and while reading second file if the ID appears in the array I need to print $0 else skip. After a long gap I am... (6 Replies)
Discussion started by: paresh n doshi
6 Replies

9. UNIX for Dummies Questions & Answers

Deleting file basing on the timestamp substring in the file name

Hello, I have in my backup folder, files with names convention like this : randomFileNames_13-02-2014_23h13m09+1392333189 randomFileNames_14-02-2014_02h13m09+1392343989 randomFileNames_14-02-2014_04h13m09+1392351189 etc.... Base on timestamp at end of the filename, I would to delete all the... (7 Replies)
Discussion started by: thuyetti
7 Replies

10. Programming

C program to read a binary file and search for a string?

Hi, I am not a C programmer. The only C exposure I have is reading and completing the exercises from the C (ANSI C ) Programming Language book:o At the moment, I am using the UNIX strings command to extract information for a binary file and grepping for a particular string and the value... (3 Replies)
Discussion started by: newbie_01
3 Replies
dbm(3UCB)					     SunOS/BSD Compatibility Library Functions						 dbm(3UCB)

NAME
dbm, dbminit, dbmclose, fetch, store, delete, firstkey, nextkey - data base subroutines SYNOPSIS
/usr/ucb/cc [ flag ... ] file ... -ldbm #include <dbm.h> typedef struct { char *dptr; int dsize; }datum; int dbminit(file); char *file; int dbmclose(); datum fetch( key); datum key; int store( key, dat); datum key, dat; int delete(key); datum key; datum firstkey() datum nextkey(key); datum key; DESCRIPTION
The dbm() library has been superseded by ndbm (see ndbm(3C)). These functions maintain key/content pairs in a data base. The functions will handle very large (a billion blocks) databases and will access a keyed item in one or two file system accesses. key/dat and their content are described by the datum typedef. A datum specifies a string of dsize bytes pointed to by dptr. Arbitrary binary data, as well as normal ASCII strings, are allowed. The data base is stored in two files. One file is a directory containing a bit map and has .dir as its suffix. The second file contains all data and has .pag as its suffix. Before a database can be accessed, it must be opened by dbminit(). At the time of this call, the files file.dir and file.pag must exist. An empty database is created by creating zero-length .dir and .pag files. A database may be closed by calling dbmclose(). You must close a database before opening a new one. Once open, the data stored under a key is accessed by fetch() and data is placed under a key by store. A key (and its associated contents) is deleted by delete(). A linear pass through all keys in a database may be made, in an (apparently) random order, by use of firstkey() and nextkey(). firstkey() will return the first key in the database. With any key nextkey() will return the next key in the database. This code will traverse the data base: for (key = firstkey; key.dptr != NULL; key = nextkey(key)) RETURN VALUES
All functions that return an int indicate errors with negative values. A zero return indicates no error. Routines that return a datum indi- cate errors with a NULL(0) dptr. SEE ALSO
ar(1), cat(1), cp(1), tar(1), ndbm(3C) NOTES
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. The .pag file will contain holes so that its apparent size may be larger than its actual content. Older versions of the UNIX operating sys- tem may create real file blocks for these holes when touched. These files cannot be copied by normal means ( cp(1), cat(1), tar(1), ar(1)) without filling in the holes. dptr pointers returned by these subroutines point into static storage that is changed by subsequent calls. The sum of the sizes of a key/content pair must not exceed the internal block size (currently 1024 bytes). Moreover all key/content pairs that hash together must fit on a single block. store will return an error in the event that a disk block fills with inseparable data. delete() does not physically reclaim file space, although it does make it available for reuse. The order of keys presented by firstkey() and nextkey() depends on a hashing function, not on anything interesting. There are no interlocks and no reliable cache flushing; thus concurrent updating and reading is risky. The database files (file.dir and file.pag) are binary and are architecture-specific (for example, they depend on the architecture's byte order.) These files are not guaranteed to be portable across architectures. SunOS 5.10 20 Feb 1997 dbm(3UCB)
All times are GMT -4. The time now is 10:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy