# byte swap



## 10313 (Aug 25, 2000)

does anyone know a way of reversing the byte order (big endian/little endian) of a binary file in UNIX?


----------



## codejockey (Feb 11, 2002)

You might check out the dd command and the conv=swab (and similar) options.

The basic syntax is: dd if=input-filename of=output-filename [options] where input-filename and output-filename default to stdin and stdout, respectively. So, for example, to copy a file named gack to a file named blort so that blort will have a byte-reversed order relative to gack you would use:

dd if=gack of=blort conv=swab

Note that dd will also allow you to perform many other conversions (even ASCII-EBCDIC!) as well as re-blocking. Hope this helps.


----------

