helm/bin/base
Henrik Lissner 6857049709 Add bin/base
2017-04-25 03:16:53 -04:00

13 lines
292 B
Bash
Executable file

#!/usr/bin/env bash
# Converts a number from one base to another. DEST_RADIX is optional and
# defaults to 10.
#
# Usage: base [SRC_RADIX] [NUMBER] [DEST_RADIX]
# Examples:
# + base 2 110 #=> 6
# + base 2 110 10 #=> 6
# + base 16 FF #=> 6
bc <<< "obase=${3:-10};ibase=$1;$2"