daily pastebin goal
26%
SHARE
TWEET

droot

h8rt3rmin8r Dec 30th, 2018 (edited) 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/bash
  2. #
  3. #   DIGITAL ROOT CONVERSION SCRIPT - (droot.sh)
  4. #   Created by h8rt3rmin8r on 20181231
  5. #   Source code: https://pastebin.com/raw/LcK5etiz
  6. #
  7.  
  8. # Variable declarations
  9. LIST_A=""; LIST_B=""
  10.  
  11. # Function declarations
  12. function numredux_var() {
  13.     REDUX_MOD=""; REDUX_VAR="$1"
  14.     if [[ "$(echo ${REDUX_VAR} | wc -c)" -ge 21 ]];
  15.     then
  16.         REDUX_MOD=$(echo $REDUX_VAR | sed 's/.\{1\}/& /g' | sed 's/ /+/g' | rev | cut -c 2- | rev | bc)
  17.         numredux_var "${REDUX_MOD}"
  18.         return
  19.     else
  20.         while [ $REDUX_VAR -gt 9 ]
  21.         do
  22.             REDUX_MOD=$(echo $REDUX_VAR | sed 's/.\{1\}/& /g' | sed 's/ /+/g' | rev | cut -c 2- | rev | bc)
  23.             REDUX_VAR="$REDUX_MOD"
  24.             if [[ "${REDUX_VAR}" == 1 ]]; then break; fi
  25.         done
  26.     fi
  27.     echo ${REDUX_VAR}; return
  28. }
  29.  
  30. # Input filtering and core process execution
  31. if [[ "$1" =~ ^-?[0-9]+$ ]];
  32.     then numredux_var "$1"; exit 0
  33.     else echo "ERROR: You must pass a NUMERIC input."; exit 1
  34. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top