user3967216
user3967216

Reputation:

Hex Editing From A Bash File

I need to know how to hex edit from a bash file. For example,

hedit 0x0 A

This would write A to offset 0x0

Upvotes: 2

Views: 2236

Answers (1)

enrico.bacis
enrico.bacis

Reputation: 31484

You should be able to use dd to overwrite parts of a file like this:

printf '\x0a' | dd of=filetopatch bs=1 seek=0 count=1 conv=notrunc 

The meaning of the arguments are:

  • of=filetopatch : the file to patch (the output file)
  • bs=1 : change 1 byte at a time
  • seek=0 : move to offset 0 (decimal) before writing
  • count=1 : copy only 1 input block
  • conv=notrunc : do not truncate the output after the edit

Upvotes: 1

Related Questions