Preview:
Write a shell script that accepts two integers as its arguments and computers the value of 
first number raised to the power of the second number. 
Script:
if [ $# -ne 2] then
echo “check the number of arguments” 
fi
count=1
result=1
if [ $2 –ge 0 ] then
while [ $count –le $2 ] do
result=`expr $result \* $1` 
count=`expr $count + 1`
done
echo “The Result is : $result”
fi
Output:
sh power.sh 5 2
The Result is: 25
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter