Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit binary file on Unix systems [closed]

On Windows machines there are lots of third party editors available to edit a binary file.

Any idea how can I edit a binary file on Unix system?

like image 466
Hemant Avatar asked May 08 '09 10:05

Hemant


People also ask

How do I edit a file in Unix without opening it?

Yes, you can use 'sed' (the Stream EDitor) to search for any number of patterns or lines by number and replace, delete, or add to them, then write the output to a new file, after which the new file can replace the original file by renaming it to the old name.

Can a binary file be edited?

To open the Binary Editor on an existing file, go to menu File > Open > File, select the file you want to edit, then select the drop arrow next to the Open button, and choose Open With > Binary Editor.

How do I edit a .bin file in Linux?

Once the file is open, press ESC and then type :%! xxd -b and then press ENTER . Press ESC and then i for "INSERT" mode which allows you to edit.


2 Answers

In vim You can type :%!xxd to turn it into a hexeditor. :%!xxd -r to go back to normal mode. xxd is shipped in a vim installation.

See here for some remarks about editing binary files with vim (boils down to :set binary to avoid trouble, use only the "R" or "r" command to change text, don't delete characters).

If You are an Emacs fan, see here for a guide on how to edit a binary file with Emacs.

like image 58
Paweł Polewicz Avatar answered Oct 12 '22 01:10

Paweł Polewicz


You can also try ghex2 GNOME utilities. This give you the automated hex-to-ASCII on the side, as well as the various character/integer decodes at the bottom. ghex2
(source: googlepages.com)

like image 34
Shannon Nelson Avatar answered Oct 12 '22 03:10

Shannon Nelson