Advertisement
Guest User

Untitled

a guest
May 29th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.27 KB | None | 0 0
  1. #!/bin/bash
  2. s="${1:-bash}"
  3. bc=''
  4. for i in $(eval echo {0..$(( ${#s} - 1 ))}); do
  5.   ord=$(echo -n "${s:$i:1}" | od -An -td1)
  6.   exp="2^$(( ((${#s}-$i-1))*8))"
  7.   [[ $exp == 0 ]] && exp=1
  8.   bc+=$(echo "$ord*$exp+")
  9. done
  10. echo $(echo ${bc:0:-1} | bc)P | tr -d '\\ '
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement