Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse hexadecimal number using shell scripts

Tags:

bash

I am trying to reverse a hexadecimal number in Bash or any other shell.

For example, I want to reverse the hexadecimal number 4BF8E and the answer should be 71FD2, i.e bitwise reversal.

like image 274
OgANgA Avatar asked Sep 17 '26 10:09

OgANgA


1 Answers

echo 4BF8E | rev | tr '0123456789ABCDEF' '084C2A6E195D3B7F'

Explanation:

  • rev reverses 4BF8E to E8FB4
  • tr maps each hexadecimal value to it's bit-reversed value
like image 54
Aki Suihkonen Avatar answered Sep 18 '26 23:09

Aki Suihkonen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!