Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Split binary file every occurrence of a group of characters Post 302787951 by drl on Sunday 31st of March 2013 02:06:01 PM
Old 03-31-2013
Hi.

Observations:
Quote:
Originally Posted by PatrickE
Why is it so complicated for software to split a file on every occurrence of a word or number and keep the first 12 letters before that in the same files. LOL
...
So far I found a few codes i though might help me but they don't search binary they serch text. ...
Because, in part:
Quote:
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
-- Unix philosophy - Wikipedia, the free encyclopedia

The perl language has facilities for reading byte-streams (read a block of data, use function unpack after reading the file). I have used it to read mixed-mode files -- ASCII intertwined with "binary" floating-point and integer internal values.

Now that I think about it, COBOL probably can do that as well, at least for some well-defined formats. I recall some folks in the Physics department where I worked using COBOL to process satellite data because of the superior record-handing characteristics.

However, in general, I try to stay as far away from such files as I can.

Best wishes ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: Averell
1 Replies

2. Shell Programming and Scripting

Split these into many ...(/etc/group)!!

Guys Following input line is from /etc/group file.As we know last entry in a line of /etc/group is userlist (all the users belonging to that group). I need to splilt this one line into 3 lines as shown below (3 because userlist has 3 names in it). Input: lp:!:11:root,lp,printq ... (13 Replies)
Discussion started by: ak835
13 Replies

3. Shell Programming and Scripting

Split file by data group

Hi all, I'm having a little trouble solving a file split I need to get done. I have the following data: 1. Light 1A. Light Soft texture: it's soft color: the color value is that of something light vital statistics: srm: 23 og: 1.035 sp: 1.065 comment: this is nice if you like... (8 Replies)
Discussion started by: mkastin
8 Replies

4. 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

5. Shell Programming and Scripting

remove last characters after %EOF (pdf binary file)

Hi, I want to know how I can remove the last characters of ANY pdf file. I read it under "od" in the command shell to see which were the last characters: $od corruptedfile.pdf -c When I see the file, I need to keep only the last characters, or "end of the file": %EOF (obviously keeping all... (1 Reply)
Discussion started by: diegugawa
1 Replies

6. Shell Programming and Scripting

split file based on group count

Hi, can some one please help me to split the file based on groups. like in the below scenario x indicates the begining of the group and the file should be split each with 2 groups below there are 10 groups it should create 5 files. could you please help? (4 Replies)
Discussion started by: hitmansilentass
4 Replies

7. Shell Programming and Scripting

Deleting all characters before the last occurrence of /

Hi All, I have a text file with the following text in it: file:///About/accessibility.html file:///About/disclaimer.html file:///About/disclaimer.html#disclaimer file:///pubmed?term=%22Dacre%20I%22%5BAuthor%5D file:///pubmed?term=%22Madigan%20J%22%5BAuthor%5D... (8 Replies)
Discussion started by: shoaibjameel123
8 Replies

8. 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

9. UNIX for Dummies Questions & Answers

counting occurrence of characters in a string

Hello, I have a string like this 0:1:2:0:2:2:4:0:0:0:-200:500...... what i want is to break down how many different characters are there and their count. For example for above string it should display 0 - 5 times 1 - 1 times 2 - 3 times 4 - 1 times . . . I am stuck in writing... (8 Replies)
Discussion started by: exit86
8 Replies

10. Shell Programming and Scripting

Split a big file into multiple files based on first four characters

I have a requirement to split a huge file to smaller text files based on first four characters which look like ABCD 1234 DFGH RREX : : : : : 0000 Each of these records are OF EQUAL bytes with a different internal layout based on the above first digit identifier.. Any help to start... (5 Replies)
Discussion started by: etldev
5 Replies
HEXBIN(1)						      General Commands Manual							 HEXBIN(1)

NAME
hexbin - Macintosh file de-binhexer SYNOPSIS
hexbin [ - options ] [ files ] DESCRIPTION
hexbin takes the text files specified in files (or standard input if none is specified) and converts them subject to the options specified. OPTIONS
In the absence of any options, hexbin takes the specified files and silently converts them into MacBinary format, giving the output files ".bin" extensions and placing them in the current working directory. -3 Write files in fork format (.info, .data and .rsrc files.) -f As -3, but empty data and rsrc files are not created. -r Write resource forks only (.rsrc files.) -d Write data forks only (.data files.) -u As -d, but the codes for CR and LF are interchanged, the filename extension is .text. -U As -u, but there is no filename extension. -a Write files in AppleShare format. This option is only valid if the program is compiled with support for some form of AppleShare. The current directory must be a valid AppleShare folder. -s Write extracted files to standard output in MacBinary format. -l List every file extracted (and every directory/folder created etc.) -v Like -l, but more verbose. When this option is specified all lines skipped because they do not belong to the hexified format are listed (implies -l.) -i Do not convert, give information only (implies -l.) -c Do not check whether the hexified lines have equal size. Normally the hexifiers gives text files with equal length line size, hexbin uses this in its heuristics to determine whether a line must be skipped. There are however hexified files that do not con- form to that pattern. If this option is specified hexbin will in general be unable to detect whether a line is garbage or not, so you have to remove the garbage by hand. -n name Gives the Unix base file name for the converted files. For files hexified with BinHex 4.0 or compatible hexifiers this flag is not needed; hexbin will determine the Unix file name based on the Mac file name. For files in dl, hex or hcx format this parameter may be needed as these formats do not include the Mac filename. Normally hexbin will in those cases base the Unix file name on the text file name, but that can be overruled with this parameter. -V Gives the patchlevel of the program, and other information. Other options are ignored and the program quits immediately. -H Give short information about the options. Other options are ignored and the program quits immediately. BUGS
As this is a beta release, there may still be some problems. SEE ALSO
macutil(1) AUTHOR
Dik T. Winter, CWI, Amsterdam, The Netherlands (dik@cwi.nl) Parts of the code are based on codes from: ahm (?), Darin Adler, Jim Budler, Dave Johnson, Dan LaLiberte, Jeff Meyer, Guido van Rossum. 3rd Berkeley Distribution October 22, 1992 HEXBIN(1)
All times are GMT -4. The time now is 11:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy