LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Migration of data file in Unix to linux (https://www.linuxquestions.org/questions/linux-newbie-8/migration-of-data-file-in-unix-to-linux-896648/)

pandunr 08-10-2011 09:12 PM

Migration of data file in Unix to linux
 
We planned to migrate data files in Unix to Linux. The file in Unix is in big endian data format where is linux is configured as little endian byre structure. This is causing problem in data computation.

Can any help

How data can be ported to linux ( converting big endian to little endian).

How linux configured can be configured for big endian byte structure.

jdkaye 08-10-2011 11:42 PM

Quote:

Originally Posted by pandunr (Post 4439219)
We planned to migrate data files in Unix to Linux. The file in Unix is in big endian data format where is linux is configured as little endian byre structure. This is causing problem in data computation.

Can any help

How data can be ported to linux ( converting big endian to little endian).

How linux configured can be configured for big endian byte structure.

Is this what you want?
C++ General: How do I convert between big-endian and little-endian values?
ciao,
jdk

flamelord 08-10-2011 11:43 PM

You could use the functions in arpa/inet.h to convert from host to network byte order, and back from network to host. Note that this is dependent on the length of the integer.

I don't know of any way to convert an arbitrary file, since a program that did that wouldn't know how the data is organized in the file. The inet.h also doesn't appear to have functions for 64-bit integers or floating point numbers, if that is an issue for you.

You might also want to look at http://www.codeguru.com/forum/showthread.php?t=292902.
Edit: jkdaye beat me to it.

allend 08-11-2011 12:49 AM

If you simply need to swap bytes, then 'dd' with the 'conv=swab' option is a possibility.


All times are GMT -5. The time now is 04:21 AM.