Write a shell script to calculate the loss percentage of an article, given the cost price and the selling price as command-line arguments
Code:
echo "Input the cost price of an item"
read cp
echo "Input the selling price of the item"
read sp
if [ $cp -eq $sp ]
then
echo "No Profit or No Gain"
fi
if [ $cp -gt $sp ]
then
s=$((cp - sp))
echo "Loss of Rs:$s"
else
s=$((sp - cp))
echo "Profit of Rs:$s"
fi
Output:
Tags:
Shell Script