Created
October 15, 2023 15:58
-
-
Save itsmikita/2aa9c434344e987a5e438eb4356c5a7e to your computer and use it in GitHub Desktop.
Convert Decimals to Hexadecimals and backwards in Shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# convert decimal (0-255) to hexadecimal (00-FF) | |
function d2h() { printf "%X\n" $1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# convert hexadecimal (00-FF) to decimal (0-255) | |
# don't forget to prepend "0x" | |
function h2d() { printf "%d\n" $1 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment