Home » Unix » shell script » write a shell script for number System[Decimal , Binary ,Octal , Hexadecimal]

write a shell script for number System[Decimal , Binary ,Octal , Hexadecimal]





clear
while true 
do
	clear
	echo "Enter your Input Base"
	echo "(Binary-2)\n(Octal-8)\n(Decimal-10)\n(Hexa-Decimal-16)"
	read ib

	echo "Enter number you want to convert"
	read num 

	echo "Enter your output Base"
	echo "(Binary-2)\n(Octal-8)\n(Decimal-10)\n(Hexa-Decimal-16)"
	read ob 
	
	ans=$(echo "obase=$ob;ibase=$ib;$num" | bc)
	echo $ans
	
	echo "Do you want to run again?(y/n)"
	read ch
	if [ $ch = "n" ]
	then
		break
	fi	
done

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *