Issue
how can I convert big endian to little endian. I need to convert data from a file.
000000000000200200DC082DED2DEDED051F4032400454036A9891D53C370101EA0A
output:
0AEA0101373CD591986A0354044032401F05EDED2DED2D08DC000220000000000000
thanks Ketan
found this script on the forum but it only does one at a time:
#!/bin/bash
# check 1st arg or stdin
if [ $# -ne 1 ]; then
if [ -t 0 ]; then
exit
else
v=`cat /dev/stdin`
fi
else
v=$1
fi
i=${#v}
while [ $i -gt 0 ]
do
i=$[$i-2]
echo -n ${v:$i:2}
done
echo
Solution
To read a file containing hex digits and reverse it using bytes, where each byte is represented by two hex digits:
#/bin/bash
while read -r line
do
tac -rs .. <<< "$line"
done
Save it as e.g. rev.sh
, chmod +x rev.sh
, and run: rev.sh < myfile
Answered By - k314159 Answer Checked By - Terry (WPSolving Volunteer)