Skip to main content

Simple Binary Replacement [Resolved]

I tried using bbe as below

bbe -e 's/01110011/01111000/' test.txt

All I'm trying to accomplish in this example is to read the file as if it's a binary file, and replacing the letter s with x.

I'm open to alternative solutions, I'm not stuck on bbe


Question Credit: Andrew Wei
Question Reference
Asked June 24, 2019
Posted Under: Unix Linux
42 views
1 Answers

To my knowledge, bbe cannot use binary (base 2) patterns directly. Hexadecimal, octal, or decimal work, however:

# Hex:
$ echo 'xs' | bbe -e 's/\x73/\x78/'
xx
# Octal:
$ echo 'xs' | bbe -e 's/\0163/\0170/'
xx
# Decimal:
$ echo 'xs' | bbe -e 's/\115/\120/'
xx

credit: Jim L.
Answered June 24, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA