byteswap file ... byteswap -4 file ...
This function byteswaps one or more files in place. This is often useful when working with short-integer binary data created on IBM PC's or DEC VAX's. If a file contains an odd number of bytes, byteswap will not touch the last byte.
This function will not prompt for files if none are provided on the command line.
The -4 option is provided to byte-rotate every four bytes, e.g., abcd is converted to dcba. This is useful when working with 4-byte integer data created on IBM PC's or DEC VAX's. If a given file contains 4*N + M bytes, then byteswap -4 will not touch the last M bytes.
The following example byteswaps trivial 26-character and 27-character files.
% % od -c xxx 0000000 a b c d e f g h i j k l m n o p 0000020 q r s t u v w x y z 0000032 % % byteswap xxx % % od -c xxx 0000000 b a d c f e h g j i l k n m p o 0000020 r q t s v u x w z y 0000032 % odin% od -c yyy 0000000 a b c d e f g h i j k l m n o p 0000020 q r s t u v w x y z \\n 0000033 % % byteswap yyy % % od -c yyy 0000000 b a d c f e h g j i l k n m p o 0000020 r q t s v u x w z y \\n 0000033 %
Last Update: $Date: 2001/09/20 12:08:17 $