How to convert binary file into text file in linux
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
How to convert binary file into text file in linux
I am trying to run a fluid simulation in Scilab, creating a 2d velocity field. For this the simulation is being run using linux which creates a binary file of data. I need to convert this into a basic text file that you would use on windows notepad, the data when converted to a normal text file should show a matrix of numbers. Does anyone have any idea how this can be done? Cheers
the simulation is being run using linux which creates a binary file of data
I'm not quite sure what you mean by "binary file of data"? What exact format is this "binary file" and what programs in linux are supposed to run it. Usually the program that runs the binary file should have an option of saving the data in a text file.
Here was the source code to dump the data into binary files, i need to instead of "write" read the binary file and convert it into a text file, will something like base64 work?
And if you look at the data, it has varying sizes - ny, nz, and nk.
None of which are contained within the file... so the file itself is arbitrary.
Just converting it to a base64 representation won't make it readable by anything.
Now if the machine architectures are compatible (as in using IEEE floating point, and same endian form) then just moving the binary file is sufficient for some compatible program to read (maybe - not sure what Windows does for binary files).
Basically i am running a simulation in linux which has about 20 sourcecode files. I am new to linux and dont really understand how the whole process works but i was told i need to get the binary data that the simulation produces and convert it into a text file that i have written a program for in Scilab to read the text file and produce a velocity vector graphic simulation. I have a couple of sourcecode files for dumping the data and writing the file. I also have a folder which contains various files which contains the binary data. Overall the text files should produce numerical matrices that Scilab can read. The problem is that when the simulation is running it takes timestamps of the simulation and creates a new file for the data so i have a bunch of files for each timestamp giving different data. A Folder called cs in linux has all the data in the folder which has various files named e.g 2426, 2427,2428 etc each in it has data at a particular time in the simulation in binary. Does that help? is there anymore information i could provide that would provide a more clear indication of the problem in terms of coding? Cheers
i am not familiar with scilab so sorry if this is off-base, but it seems like what you are trying to do would be similar to converting an .mp3 audio file into ascii-text. (i know whenever i passed in my matlab assignments the code and output was always text unless there were a few plots i needed to print out).
i know in the case of things like open-office or microsoft word there is an option to file -> save as -> 'text' that can be read in vi or notepad.exe (does scilab have a similar export feature ?
looks like you written a program that is supposed to convert certain values to ascii text. how big is the output, i dont know scilab but can you upload a dump of the output somewhere and list what you would want as the expected output.txt (i suspect something can be written in 'c' to parse it).
So you wrote a program (or are using a program) that writes some random format binary file.
Then you wrote a program that reads in some random format ASCII file.
And now you need a program to convert the random format binary file into a random format ASCII file? Why didn't you just write your data parser to read the original binary files instead of some random ASCII format that doesn't exist? Why can't you modify the code that's writing the binary files so that it writes ASCII instead in the format you want?
This whole situation makes no sense to me. And it has nothing at all to do with Linux vs Windows.
I guess the main question is, why did you write your Scilab program so that it reads in ASCII files that don't exist rather than the binary files that do?
To answer the original question, "How to convert binary file into text file in linux" - you write a custom program to parse the binary file and write out the data in ASCII, same as you would in Windows.
Last edited by suicidaleggroll; 02-24-2014 at 11:29 AM.
I don't think Linux or operating systems are your problem here.. Rather you need someone that's familiar to Scilab... Please stop involving operating systems here since they have nothing to do with your problem..
From what I gather.. You need to create your own program that reads that specific file format (which happens to be in a binary form) and convert it to plain text (it will need to even respect your pattern/format so it can be usable in your other Scilab program)... I can assure you that no one else can do this for you..