You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
336 B
22 lines
336 B
#!/bin/bash
|
|
#
|
|
# Converts a big-endian hex string to a little-endian hex string.
|
|
#
|
|
# Examples:
|
|
#
|
|
# ./be_to_le.sh 0x12345678
|
|
# 0x78563412
|
|
#
|
|
# ./be_to_le.sh 12345678
|
|
# 0x78563412
|
|
|
|
BE_VALUE=$1
|
|
|
|
# If the input starts with 0x, strip it off.
|
|
if [[ $BE_VALUE =~ ^0x.* ]];
|
|
then
|
|
BE_VALUE=${BE_VALUE:2}
|
|
fi
|
|
|
|
echo 0x`echo -n $BE_VALUE | tac -rs ..`
|