Binary search and replace


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Binary search and replace
# 8  
Old 05-28-2014
Quote:
Originally Posted by useretail
I understand that in linux everything goes, but let's face it - hexdump wasn't made for that purpose.
Cough...
What? "hexdump" is excellent for creating an ASCII version array quickly of a pure binary file to work on before reconverting back to pure binary again.
However if hexdump is not good enough for you then go with Perl or Python. Python being probably the better of the two for this application...

EDIT:

hexdump creating /bin/bash into a 4+MB ASCII data file.
Code:
Last login: Wed May 28 18:01:35 on ttys000
AMIGA:barrywalker~> time bin_text=`hexdump -v -e '1/1 "%02X "' /bin/bash`

real	0m0.296s
user	0m0.314s
sys	0m0.021s
AMIGA:barrywalker~> ls -l /bin/bash
-r-xr-xr-x  1 root  wheel  1371648  9 May  2012 /bin/bash
AMIGA:barrywalker~> echo "${#bin_text}"
4114944
AMIGA:barrywalker~> _

Not bad for speed eh!
It takes double that time to put it into an array format directly.

Last edited by wisecracker; 05-28-2014 at 02:08 PM.. Reason: See above...
# 9  
Old 05-28-2014
Quote:
Originally Posted by drl
Hi.

I'd guess that the OP meant Byte or Binary File Search and Replace. We would not expect that everyone knows that there is an efficient procedure for searching ordered collections that goes by that name http://en.wikipedia.org/wiki/Binary_search_algorithm ... cheers, drl
Thanks.
I misread it as (binary search) (and replace) instead of (binary) (search and replace). I must not be getting enough sleep.
# 10  
Old 05-28-2014
Hi.

On a system like:
Code:
OS, ker|rel, machine: Linux, 3.2.0-4-amd64, x86_64
Distribution        : Debian 7.4 (wheezy, workstation-vm)

A look through the repository yields:
Code:
bbe - sed-like editor for binary files
beav - binary editor and viewer
bvi - binary file editor

Best wishes ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

How to search specific object in binary file?

I have a very important question: I have to find a table 'XXTO_AR_TABLE' in a folder present in server and in this folder these types files are present: .rdf, jar file, java class file etc. These are binary files. I want to get name of these files where my table named 'XXTO_AR_TABLE' is... (2 Replies)
Discussion started by: Vikash163
2 Replies

3. Programming

Binary search tree questions. Please help =)

I have some questions about certain placement of child nodes since I'm just learning BSTs and it's quite confusing even after reading some sources and doing some online insertion applets. Let's say I want to add nodes 5,7,3,4 to an empty basic BST. ... (1 Reply)
Discussion started by: Jill Ceke
1 Replies

4. Shell Programming and Scripting

Regex and backreference to replace in binary file

Hello to all, I have this sed script that replaces hex strins within a binary file. As you can see, I want to replace all bytes 4X with 2X (where X could take values 0 to F). sed -e 's/\x40/\x20/g' -e 's/\x41/\x21/g' -e 's/\x42/\x22/g' -e 's/\x43/\x23/g' -e 's/\x44/\x24/g' -e... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

5. Programming

Binary Search Tree Search problem

I am writing code for a binary search tree search and when I compile it i am getting strange errors such as, " /tmp/ccJ4X8Xu.o: In function `btree::btree()': project1.cpp:(.text+0x0): multiple definition of `btree::btree()' " What does that mean exactly? tree.h #ifndef TREE_H #define... (1 Reply)
Discussion started by: meredith1990
1 Replies

6. Shell Programming and Scripting

search 32 bit binary for the 1's and return a 1 to the placeholder variable

Folks , I have a korn shell script that i have written for assembly, the variable that is a final result is returning hexadecimal, now the value is to be converted to binary and return the place holder in the binary that has a 1 in its place and send it to a variable assigned for the... (0 Replies)
Discussion started by: venu
0 Replies

7. Shell Programming and Scripting

How to search for string and return binary result?

Hi, I have a problem that I am sure someone will know the answer to. Currently I have a script which returns a binary output if it finds a certain search string (in this case relating to a DRBD cluster) as follows: searchstring="cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate" && echo... (3 Replies)
Discussion started by: almightybunghol
3 Replies

8. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

9. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

10. 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
Login or Register to Ask a Question