Find endianness of a system

In order to find if a Linux/UNIX based system is either Big-endian or Little-endian use this script:

echo I | tr -d [:space:] | od -to2 | head -n1 | awk '{print $2}' | cut -c6

In a Little-endian system it should produce 1 and on a Big-endian system it should produce 0.

The script is known to not work properly on macOS.

If you need more information on what is endianness of a system then this is your place to find out.

If you need a brief, very short and general info, then – if you have the number 123, Big-endian system will write this number on its harddrive (for example) like 123, Little-endian system will write it like 321.

Leave a Reply