midwire
7/10/2014 - 1:16 PM

Check Endian-ness

Check Endian-ness

#!/bin/bash
# Check Endian-ness

x=`echo -n I | od -to2 | head -n1`
e=`echo $x | cut -f2 -d' ' | cut -c6`

if [[ $e -eq 0 ]]; then
  echo "This system is Big Endian"
elif [[ $e -eq 1 ]]; then
  echo "This system is Little Endian"
else
  echo "Error"
fi