h8rt3rmin8r

decimal2base12.sh

Jan 2nd, 2019
167
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/bash
  2. # BASE 12 - DECIMAL INPUT CONVERSION SCRIPT
  3.  
  4. function decimal2base12() {
  5.     number=$(echo "$1" | tr -s '[:lower:]' '[:upper:]' )
  6.  
  7.     # "obase" = The base to convert into
  8.     #
  9.     # "ibase" = The base you are coming from as expressed in the base you
  10.     #           want to convert into
  11.  
  12.     result=$(echo "obase=$obase;ibase=$ibase;$number" | bc)
  13.  
  14.     if [ ! "$?" == "0" ]; then echo ""; exit 1; fi
  15.     echo "$result"
  16. }
  17.  
  18. obase=12
  19. ibase=A
  20. decimal2base12 "$1"
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×