Shell Script to Multiply Two Numbers

shell script is a computer program designed to be run by the Unix shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. Typical operations performed by shell scripts include file manipulation, program execution, and printing text. A script that sets up the environment, runs the program, and does any necessary cleanup, logging, etc. is called a wrapper.

In this post, we will write a shell script to multiply two numbers the are taken from the input and display the output.

INPUT:
The first line contains two space-separated numbers: a and b

OUTPUT:
Print one number which is the product of a and b

The following is the shell script to multiply two numbers:

echo enter a and b
read a b
c=`expr $a \* $b`
echo $c

OUTPUT:

$ enter a and b
$ 4 5
$ 20

Let us know in the comments if you are having any questions regarding this shell script.

And if you found this post helpful, then please help us by sharing this post with your friends. Thank You

Leave a Reply