Guest User

Untitled

a guest
Feb 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #This is a simple calc for looking glass
  4. #Licenced by WTFPL
  5. #by NeoTheFox 2018
  6.  
  7. #USAGE:
  8. #glasscalc.sh WidthxHeight
  9.  
  10. function printhelp
  11. {
  12. echo "Usage:"
  13. echo " glasscalc.sh widthxheight"
  14. echo "Example:"
  15. echo " glasscalc.sh 800x600"
  16. }
  17.  
  18. if [ -z $1 ]
  19. then
  20. echo "No arguments provided"
  21. printhelp
  22. exit 0
  23. fi
  24.  
  25. WIDTH=$(echo $1 | cut -d "x" -f1)
  26. HEIGHT=$(echo $1 | cut -d "x" -f2)
  27.  
  28. ((M=$WIDTH*HEIGHT*4*2))
  29. ((M=M/1024/1024))
  30. ((M+=1))
  31. ((M|=M>>1))
  32. ((M|=M>>2))
  33. ((M|=M>>4))
  34. ((M|=M>>8))
  35. ((M|=M>>16))
  36. ((M+=1))
  37.  
  38. echo "$M"
Add Comment
Please, Sign In to add comment