Results 1 to 6 of 6
hi !
i need a help to change a binary file, let's say to find and replace username:
find string: "/home/name/bla-bla-bla/ "
new string: "/home/anewname/bla-bla-bla/ "
i can do it, ...
- 08-11-2010 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 11
search and replace in a binary file
hi !
i need a help to change a binary file, let's say to find and replace username:
find string: "/home/name/bla-bla-bla/ "
new string: "/home/anewname/bla-bla-bla/ "
i can do it, for example, in emacs (hexl-mode), but interesting in writing a script instead. it will be much more better for me if i could do it automatically.
is there an analog of: sed 's/string1/string2/g' ?
P.S. the best way is to recompile the binary files i have, but there are no sources available.
- 08-11-2010 #2Just Joined!
- Join Date
- Jul 2008
- Posts
- 81
It depends greatly on whether the binary file has other properties that must not be changed when you replace the string. Such as a fixed length, or a required checksum.
- 08-12-2010 #3Just Joined!
- Join Date
- Dec 2008
- Posts
- 11
thank you for your reply. i solved the problem. the simple SED works perfectly in my case, i only need to check that the length remains fixed. that was the actual problem... my stupid

now i can do all i want in a very simple way!
- 08-12-2010 #4
If you have root access, create a symlink if all you want to do is change the path to a home directory:
ln -s /home/name /home/anewname
- 08-12-2010 #5
- 08-12-2010 #6Just Joined!
- Join Date
- Dec 2008
- Posts
- 11
thank you for the answers.
to jippie: that is clearly an option, i'll keep it mind
to unlimitedscolobb: yes, agree. that is how i finally did it.


Reply With Quote
