Sponsored Content
Top Forums UNIX for Advanced & Expert Users Modifying binary file by editing Hex values ? Post 88378 by Perderabo on Thursday 3rd of November 2005 01:30:10 PM
Old 11-03-2005
My od barfs on "od -h". I am not sure AIX can run this script. But it might give you an idea on how to do it on AIX. I took a core file as my file to be edited. And I build a 60 byte patch file. I made it all "FF" since my core file had a bunch of zeros in that range. Then I dump the interesting section of the core file, install the patch, and then dump the core file file a second time. It works for me.
Code:
#! /usr/bin/ksh

print -n aaaaaaaaaa > temp
print -n aaaaaaaaaa >> temp
print -n aaaaaaaaaa >> temp
print -n aaaaaaaaaa >> temp
print -n aaaaaaaaaa >> temp
print -n aaaaaaaaaa >> temp
tr "a" "\177" < temp > patch
od -v -A x -t x2 patch

echo
od -v -A x -t x2 < core | sed '1,20d;30q'

dd if=patch bs=1 conv=notrunc of=core seek=364 count=60

echo
od -v -A x -t x2 < core | sed '1,20d;30q'
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Binary and hex in unix

not much familiar with binary and hex calculation in script programming.... explaination: binary format control the parameter turned on or off in the program stored in hex mode, the question is: how to change 39e to 19e using the binary calculation(although i don't know the command for... (2 Replies)
Discussion started by: trynew
2 Replies

2. UNIX for Dummies Questions & Answers

Hex editing

Hi, I am new to UNIX. I have a text file where each line ends on the hexadecimal character "0A". In the file there are some records that contain the Hex characters "0D0A" which I need to replace by Hex "20". Is there a simple way to do this? Regards, Swanie (3 Replies)
Discussion started by: Swanie
3 Replies

3. Shell Programming and Scripting

binary/hex output

i want to output something like 2f 00 00 00 but i can't seem to escape characters like i'm used to in some programming languages, so with this: echo "/\0\0\0" >> outputfile i actually get 2f 5c 30 5c 30 5c 30 0a ie the \0 isn't giving me the 00 i need, and in addition it has got an... (8 Replies)
Discussion started by: peterworth
8 Replies

4. Shell Programming and Scripting

Editing a content which has branched values in a file

i have a file named tt which has content: dd=/cc/vv/bb i want to edit it by a script which will give as follows: dd=/cc/vv/bb/tt i tried sed -i -e 's/dd="/cc/vv/bb"/dd="/cc/vv/bb/tt"/' tt can any one pls help me on this? (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

5. Programming

Editing binary files

I am working in C and need a solution for below problem: I have a binary file, which needs to be edited in such a way no data is loss. For example i have to insert 3 bytes of data at some position without changing the contents of the file. if file has data as:... (2 Replies)
Discussion started by: junaid.nehvi
2 Replies

6. Shell Programming and Scripting

convert hex to binary and send to variable

Folks, can anyone help with a script to convert hex to binary digits, and break the 32 bit binary into packs of 4 and send them to 8 different variables.Any help is sincerely appreciated. Thanks venu Its in korn shell...... (24 Replies)
Discussion started by: venu
24 Replies

7. Shell Programming and Scripting

Editing Binary File

Dear Experts, I have one binary file which contains multiple 31k (31744) records. Each record begins with "a6 82". So the pattern is: a6 82 (+31742 bytes) a6 82 (+31742 bytes) a6 82 (+31742 bytes) a6 82 (+31742 bytes) There are some corrupted files where record does... (6 Replies)
Discussion started by: dhiraj4mann
6 Replies

8. Shell Programming and Scripting

How to replace with "sed" some hex values by other hex values?

Assume I have a file \usr\home\\somedir\myfile123.txt and I want to replace all occurencies of the two (concatenated) hex values x'AD' x'A0' bytwo other (concatenated) hex values x'20' x'6E' How can I achieve this with the gnu sed tool? Additional question: Is there a way to let sed show... (1 Reply)
Discussion started by: pstein
1 Replies

9. Shell Programming and Scripting

Convert Binary File To Hex In Linux

dHi, I have the attached file(actual file can be extracted post unzipping it) & i am trying to use the following code for coversion to hex format. Starting hex value is 84 which is start of the record & termination is done using 00 00 followed by 84(hex) which i can see in the dump clearly using... (14 Replies)
Discussion started by: siramitsharma
14 Replies

10. Shell Programming and Scripting

Text File with Binary Values processing

Hello all, I have a txt file containing millions of lines. Below is the example: {tx:be} head -50 file.txt Instr1: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Instr1:... (6 Replies)
Discussion started by: Zam_1234
6 Replies
PICOSAT(1)						      General Commands Manual							PICOSAT(1)

NAME
picosat - SAT solver with proof and core support SYNOPSIS
picosat [options] input-file DESCRIPTION
This manual page documents briefly the picosat command. picosat is a SAT solver with proof and core capabilities. Use the picosat.trace binary to actually use these capabilities (these incur some overhead). OPTIONS
-h Show summary of options. --version print version and exit --config print build configuration and exit -v enable verbose output -f ignore invalid header -n do not print satisfying assignment -p print formula in DIMACS format and exit -i <0/1> force FALSE respectively TRUE as default phase -a <lit> start with an assumption -l <limit> set decision limit -s <seed> set random number generator seed -o <output> set output file -t <trace> generate compact proof trace file (use picosat.trace, see above). -T <trace> generate extended proof trace file (use picosat.trace, see above). -r <trace> generate reverse unit propagation proof file (use picosat.trace, see above). -c <core> generate clausal core file in DIMACS format (use picosat.trace, see above). -V <core> generate file listing core variables -U <core> generate file listing used variables AUTHOR
picosat was written by Armin Biere <biere@jku.at>. This manual page was written by Michael Tautschnig <mt@debian.org>, for the Debian project (but may be used by others). February 5, 2010 PICOSAT(1)
All times are GMT -4. The time now is 03:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy