views:

95

answers:

2

I got binary file, that contains doubles. How do i print that out to a terminal. I've tried octaldump 'od' but cant figure out the syntax I've tried something like

head -c80 |od -f

But that doesnt work, the man page for od is extremely bad.

I've made a c program that does what I want, something like assuming 10double chunks.

double tmp[10];
while(fread(tmp,sizeof(double),10,stdin))
    for(int i=0;i<10;i++)  printf("%f\t",tmp[i]);

thanks.

+4  A: 

Have you tried hexdump utility?

hexdump -e ' [iterations]/[byte_count] "[format string]" ' filename

Where format string should be "%f", byte count should be 8, and iterations the amount of floats you want to read

Kornel Kisielewicz
Thanks this is quite usefull
monkeyking
+4  A: 

The od command you're looking for is

od -t fD

(That means "floating point values, of double size").

caf