Re: edit a binary file

From: Bill Thompson (bill.thompson_at_GOODYEAR.COM)
Date: 09/09/03

  • Next message: Adams Kevin J: "Re: Moving users and print queues to another machine"
    Date:         Tue, 9 Sep 2003 15:38:49 -0400
    To: aix-l@Princeton.EDU
    
    

    Okay, nobody else bit on this so I'll give you *a* way to do it (probably
    not the only way).

    I have vim (http://www.vim.org) installed on all my computers. vim has a -b
    option to allow you to directly edit binary files. Using vim with the -b
    option in a "here to" notation would allow you to edit the file with a
    script.

    e.g.: Suppose you knew you wanted to change the characters at position
    25-29 on line 5 of a binary file with the string "abcde". The following
    script would do that.

    #!/bin/sh
    /usr/local/bin/vim -b /foo/bar/file <<END_OF_VIM
    5G25|Rabcde^[:wq!
    END_OF_VIM

    However as I'm sure you know, changing a binary file is *very* dangerous.
    Change them at your own risk

    Bill Thompson
    Sr UNIX Systems Administrator
    The Goodyear Tire & Rubber Co.

    Contains Confidential and/or Proprietary Information
    May Not Be Copied or Disseminated Without Express Consent of The Goodyear
    Tire & Rubber Company.

    AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2

     ----- Original Message -----
     From: Arthur Prince
     Newsgroups: bit.listserv.aix-l
     To: aix-l@Princeton.EDU
     Sent: Monday, September 08, 2003 6:57 AM
     Subject: edit a binary file

     I ned to be able to edit a binary file frfom a sheel script, i.e replace
     one string with another. Can awk or sed or anything do this on a binary
     file?

     Message sent via Totalise Webmail - http://www.totalise.co.uk/


  • Next message: Adams Kevin J: "Re: Moving users and print queues to another machine"

    Relevant Pages

    • Re: [SLE] grep error
      ... Any reason I can't edit out the garbage? ... I'm not sure *why* it's stored as a binary file, but I suspect that you won't ... I suspect that bash will add some more (bash updates the file every time it ...
      (SuSE)
    • Re: synaptic problem with unbuntu 5.10
      ... knowing which file to edit for a start. ... And knowing that just sticking a newline char on the end is ... a safe thing to do for a binary file ('safe'='it will work fine without ...
      (comp.os.linux.misc)
    • How to edit or browse a binary file in z/OS?
      ... I was wonder how do you edit or browse a binary file in z/OS? ... like everytime I open a binary file it automatically goes into text. ...
      (bit.listserv.ibm-main)
    • Re: Editing Binary Files
      ... I want to edit a precompiled ... pipe that into ... 'awk' script which searches for the pattern you are ... it is then processed and 'uudecode' is used to get the text back ...
      (comp.unix.questions)
    • Re: Using echo in Bash
      ... the filenames into a text file, edit it with a text, then turn the file ... > Isn't it the 'echo' command that have to do be able to echo editable text? ... > Sure=) I have made this little Bash script that converts MusePack ... > The script is called repack, ...
      (alt.linux)