Loading, please wait...

A to Z Full Forms and Acronyms

How to read two integer numbers and print the subtraction of both variables in Linux Shell Script | Linux Shell Script

Mar 07, 2022 LinuxShellScript, 4741 Views
How to read two integer numbers and print the subtraction of both variables in Linux Shell Script | Linux Shell Script

How to read two integer numbers and print the subtraction of both variables in Linux Shell Script | Linux Shell Script

We will create a shell script program to read values for variables from the user and then calculate subtraction operation and print the result on the console screen.

#!/bin/bash

echo "Enter num1: "
read num1
echo "Enter num2: "
read num2

result=`expr $num1 - $num2`

echo "Subtraction is: $result"
A to Z Full Forms and Acronyms