Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a binary file which in it there are some parameters stored as binary, for example : x , y , z , u ,p1 , p2 ,.. up to 12 parameters.

I used "Ghex" to show it, Ghex shows some hexadecimal values but I cannot understand the format of the file(how these parameters have been saved).

Is there any way(program , ...) to understand how these parameters have been saved?

share|improve this question

closed as off-topic by Eric Carvalho, Radu Rădeanu, LiveWireBT, Richard, Avinash Raj Apr 19 '14 at 19:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – Eric Carvalho, Radu Rădeanu, LiveWireBT, Richard, Avinash Raj
If this question can be reworded to fit the rules in the help center, please edit the question.

Read man od. od will let you specify any format you like. For instance, if your file is 4byte integers, you'd use od --format=dI.

It depends on what type of variables the "up to 12 parameters" are, and how much space (how many bytes) they take up in the file, and the "endian-ness" of the data (is a 4 byte integer stored as 4321 or 1234 in the file?).

If the file is too complex for od, you could look at Perl's unpack function, with perldoc -f unpack, or the Python struct module.

The real way to understand the format is to look at the program that created the file, or the documentation, or ...., track down the programmer and inquire.

Thanks to @steeldriver

share|improve this answer
+1 the Python struct module also provides a binary unpacker - it might also be worth mentioning endian-ness. – steeldriver Apr 17 '14 at 21:49
Thanks to @steeldriver – waltinator Apr 19 '14 at 4:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.