File conversion to ascii

Hi All,

I have a data file which has binary and hexa decimal data..i tried to convert that file using dd and od commands but i am getting some numbers and junk values...

Please let me know is there any other command which can convert this file to ascill.

Awaiting your responses

-Mora

If you know how the file was created, it is probably faster to write a program in the same language, to read the current file and convert the fields to ascii and then create a new output file which is all text.
If you don't know how the file was created, then you have first to decide where each field starts and ends, how to translate each field, whether there are negative numbers, and what is the record separator (if any).
"hd" will help with this.
It is also possible that there is data compression/encryption in the record, in which case you will only be able to read the file with the software that created it.

Hello Jgt,

Thanks for your quick response.

The file was created in binary mode and ftp ed to our unix box.

The file is fixed width file and it has no negative numbers.

There are no data compressions as far as i know..

Pls give me little more details about hd command..that will be helpfull

-Mora

I'm not sure where you are going with this... What will it accomplish to convert a file containing legitimate 8-bit characters into pure 7-bit representations?? Is this what you mean by ASCII (really "text"), the first 128 characters of the 256 character UTF-8 set character set???

To do the above requires that 8-bit characters be represented as 2 7-bit characters. One very early way of doing this (for file attachments when there was no other way to "attach" binary files to email) was/is called uuencode (and uudecode to change it back to original form). Your unix system will have some man pages on this program. But again I'm not sure what you are really talking about. If this was a regular TEXT file transmitted in BINARY mode by mistake then the only thing you might have to do is translate line endings -- CR/LF [windows] to LF [unix] for example. If that is what is going on you could use a simple sed script to strip CR (ascii character 13, 0d in hex)...

The hd command displays a file in hexadecimal and ascii where there is a printable character for the hex value. (otherwise it displays a dot.)

usage:
hd file |more