Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 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.

1 Answer 1

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 at 21:49
    
Thanks to @steeldriver –  waltinator Apr 19 at 4:31

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