Shell script, Perl script, command or utility to convert Binary to text
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm confused by this---all files are binary. When you READ a file, you specify (either explicitly or implicitly) how the binary data should be interpreted-----e.g. it might be read as executable code, ascii text, image data, etc.
try "hexdump -C" to see the printable characters in the file.
The file is a dump of a equipment where is in binary, binary Coded Decimal (BCD) in ISO and I expect that contains words and numbers I mean readable text.
Iḿ not sure if it matters but the application that generates the binary dump is not unix system.
One thing I noticed was that BCD can be 1 byte per number---or one byte for TWO numbers:
Quote:
compressed (or packed) BCD typically carries two numerals in a single byte by taking advantage of the fact that four bits will represent the full numeral range.
Also, look at a Google search using--eg--"BCD to ascii linux"---for example, I found one article about using dd.
Can you attach a file with a small sample of the data?
Binary, Binary BCD ISO is the only data configuration format I know.
I've attached a sample of 20 lines, I did awk 'NR<21' file to get a sample.
And in order to be able to upload the file I put the PDF extension to the file.
You can download it and remove the extension. I think the content will be intact.
first, the hexdump output--I believe the 1st 2 lines are ascii test and then some filler (ff ff ff, etc)
The next 3 lines do NOT look like ascii text, so we'll try using other methods (the rest of the file segment looks pretty much like those 3 lines.
Perhaps it would help to read my blog entry, since most of the recent articles in this thread are about what is meant by 'binary', and so on. It may also be possible to use the strings tool, which is used to find sequences of ASCII text embedded within any specified 'binary' file or stream.
If I am not mistaken, the only way to reveal ascii text in the file sample supplied would be to do some bit-shifting or decoding of some kind of encryption. Otherwise, hexdump -C pretty much tells the whole story.
If we can tolerate some semantics quibbling, I'll assert that ALL computer files are binary---ie they are sequences of 1s and 0s. That said, a prevailing definition of "binary" is something that will not decode cleanly to ascii.
Another thought: could the file be using unicode? How many bytes per character in unicode?
The file is a dump of a equipment where is in binary, binary Coded Decimal (BCD) in ISO and I expect that contains words and numbers I mean readable text.
Doesn't the equipment come with a manual that explains the dump format?
If you tell us the context (eg. source of data, full file name etc) then we MAY be be able to suggest how to go about getting the file contents in a readable form.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.