Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo -n "Enter a numnber: "
- read n
- echo -n "$n's base is: B->Bin O->Oct D->Dec H->Hex: "
- read choice
- case $choice in
- B):
- echo 'obase=10; ibase=2; '$n'' | bc
- echo 'obase=16; ibase=2; '$n'' | bc
- echo 'obase=8; ibase=2; '$n'' | bc;;
- D):
- echo 'obase=2; ibase=10; '$n'' | bc
- echo 'obase=16; ibase=10; '$n'' | bc
- echo 'obase=8; ibase=10; '$n'' | bc;;
- O):
- echo 'obase=10; ibase=8; '$n'' | bc
- echo 'obase=2; ibase=8; '$n'' | bc
- echo 'obase=16; ibase=8; '$n'' | bc;;
- H):
- echo 'obase=10; ibase=16; '$n'' | bc
- echo 'obase=2; ibase=16; '$n'' | bc
- echo 'obase=8; ibase=16; '$n'' | bc;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement