Last active
January 3, 2016 02:29
-
-
Save jpiccari/8395763 to your computer and use it in GitHub Desktop.
I found myself updating a few bytes within files often. This script quickly allows the update of 1 or more bytes so I don't have to open a hex editor for such a simple task.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$#" -ne 3 ] || ! [ -f "$1" ]; then | |
# usage | |
echo "$(basename $0) [file] [offset] [bytes]" | |
exit 1 | |
fi | |
bytes=$(printf "$3" | xxd -p) | |
printf $bytes | xxd -r -p | dd of="$1" seek=$(( $2 )) count=$(( ${#bytes} / 2 )) bs=1 conv=notrunc &> /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment