replace nulls with whitespaces in a file

Hi,

i have a file which contains data in fixed length. each row contains data of 10 characters fixed length. The data in the file appears like 4567782882

some times i may recieve dat less than fixed length of 10. in such a case i find nulls appended at the trailing spaces when i do a hexdump. i should replace this nulls with whitespaces. how could this be done?

the possiblities where i may recieve nulls in the data is:
123 678910
12345
1
etc..

in all th above cases the nulls should be replaced by white spaces

Try

$ tr '\000' '\040' filename
$ echo -e "123456789\0" | xxd
0000000: 3132 3334 3536 3738 3900 0a              123456789..
$ echo -e "123456789\0" |tr '\0' ' '| xxd
0000000: 3132 3334 3536 3738 3920 0a              123456789 .