Debian jess 64

I was wondering if it is possible to view the binary of a file in the 00101000 form and edit it, I am able to view it but in the hex form and I am looking to view and edit it in a the 8 digit form, I have been able to view it in the correct form just not edit it so I believe it is possible,

So moral of the story trying to view the binary in the 8 digit form and edit it rather then the hex.

2 Answers 2


with xxd, you can use the -b flag

echo 'hello world' | xxd -b

which will output

0000000: 01101000 01100101 01101100 01101100 01101111 00100000  hello 
0000006: 01110111 01101111 01110010 01101100 01100100 00001010  world.

you can redirect that to a file where you can edit it

echo 'hello world' | xxd -b > dumped_bits.txt

and then, leaving the coumns in place you can convert back with this (albiet hacky) script

# name this file something like `bits_to_binary.sh`

# strip anything that's not a bit string like `0000000:` or `world`
bits=`sed -ze 's/\w*[^ 01]\w*//g' -e 's/ //g' -e 's/\n//' $1`

# and convert the bit representation to binary
printf "obase=16;ibase=2;${bits}\n" | bc | xxd -r -p

and with those steps in combination, you can

echo 'hello world' | xxd -b > dumped_bits.txt
# edit dumped_bits.txt
./bits_to_binary.sh dumped_bits.txt
# hooray! the binary output from the edited bits!
  • Yes but how do I edit it? Aug 16, 2015 at 0:46
  • check the edits, that should cover it! Aug 16, 2015 at 1:31
  • great, I (and googlers) would appreciate it if you marked this as the solution! glad to hear it worked out for you! Aug 16, 2015 at 6:39

Use vim in binary mode:

vim -b filetohack.bin

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .