Berkeley CSUA MOTD:Entry 10263
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/24 [General] UID:1000 Activity:popular
5/24    

2003/9/20-21 [Computer/SW/Languages/Perl, Computer/SW/Unix] UID:10263 Activity:nil
9/19    What's the easiest way to replace text strings in a binary file?
        I have a feeling that sed can't be used with binary files...
        \- uh you can try emacs. anymore is probably beyond the scope of wall.
        \_ perl -pi -e 's/foo/bar/g' is probably pretty safe;
           add in a -0777 first if you want to be paranoid
        \_ If you're replacing same-size strings, any hex editor will do.  If
           you're shrinking them, then fill with spaces.  If you're growing,
           you might break something if it's an executable or some self
           referenced data file like a zip.
           \_ spaces?  Why not null chars?
              \_ because code accessing those strings may run into trouble
                 with nulls/
        \_ Arrr - nold for California Governor!
           \_ Avast Right-Wing Conspiracy!