Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #!/usr/bin/env sh
  2.  
  3. if [ $# -eq 0 ]; then
  4. echo "hex2bin: missing operand after 'hex2bin'"
  5. echo "USAGE: hex2bin n [...]"
  6. exit 1
  7. fi
  8.  
  9. for var in "$@"
  10. do
  11. code=$(echo "${var/0[xX]/}" | tr "[:lower:]" "[:upper:]")
  12. converted=$(echo "ibase=16; obase=2; $code" | bc)
  13. echo -n "$converted "
  14. done
  15.  
  16. echo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement