Breplace

From Scriptwiki
Jump to: navigation, search

The breplace command is used to replace values in a binary file.

breplace <&binvar> <oldvalue> <newvalue> [oldvalue newvalue...]

This replaces all matching asciivalues of the binary file &binvar to the new values.

Examples

bset 1 &test 65 66 67 68 69 65 66
breplace &test 65 97 66 98
echo -a $bvar(&test,1,$bvar(&test,0)) returns 97 98 67 68 69 97 98

This replaced all values 65 to 97 and all values 66 to 98.

bset 1 &test 65 66 67 68 69 65 66
breplace &test 65 66 66 98
echo -a $bvar(&test,1,$bvar(&test,0)) returns 66 98 67 68 69 66 98

This replaced all values 65 to 66 and all values that were 66 to 98. Notice that the values that were 65 and replaced to 66 are not replaced to 98.