rajeshkumar created the topic: Shell script that will add two nos
How to write shell script that will add two nos, which are supplied as command line argument, and if this two nos are not given show error and its usage
#!/bin/bash
#
# Linux Shell Scripting Tutorial 1.05r3, Summer-2002
#
# Written by Vivek G. Gite <vivek@nixcraft.com>
#
# Latest version can be found at www.nixcraft.com/
#
# Q1.Script to sum to nos
#
if [ $# -ne 2 ]
then
echo “Usage – $0 x y”
echo ” Where x and y are two nos for which I will print sum”
exit 1
fi
echo “Sum of $1 and $2 is `expr $1 + $2`”
#
# ./ch.sh: vivek-tech.com to nixcraft.com referance converted using this tool
# See the tool at www.nixcraft.com/uniqlinuxfeatures/tools/
#
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn
- Medical Laboratory equipment manufacturing company - December 20, 2024
- Discover the Heart of India with Mera Apna Bihar - December 20, 2024
- Experience the Pulse of Bangalore with Bangalore Orbit - December 20, 2024