Shell Scripts
Basic Shell Script Examples In Linux
Shell script examples in linux covers some of the basics of shell scripts.This example contains basic commands on linux.
If you are looking for basic shell scripts then this article is for you.
Shell Script For Showing Two Numbers Entered By User:
In this example we have define two variables.This two variable will take two vales from user.The “echo” command used for display the output.The $ sign fetch values from variable when we use it on echo command.
read a
read b
echo $a
echo $b
Shell Script For Addition Of Two Values Entered By User
In this example a and b are two variables.The x variable used for storing the addition.We use backcode “`” to execute a mathmetical expression.
echo Enter Two Numbers
read a
read b
echo The Numbers You Have Added: $a,$b
x=`expr $a + $b`
echo The Sum Is : $x
Shell Script For Checking Two Numbers Are Equal Or Not:
read a
read b
if{[$a -eq $b]
then
echo They Are Equal
else
echo They Are Not Equal
fi
You can also use this script to find the gretest value in two numbers.
read a
read b
read c
if[$a -gt $b -a $a -gt $c]
then
echo A is greater
elif [$b -gt $a -a $b -gt $c]
then
echo B Is Greater
else
echo C Is Greater
Printing Numbers For A Particular Range
echo Enter Two Ranges
read m
read n
i=$m
while [$i -le $n]
do
echo $i
let i=i+1
done
Division Of Two Numbers:
echo "Enter Two Numbers"
read a
read b
t=`expr $a / $b`
echo "The Division Is"
echo $t
Find Factorial Of A Number:
fact=1
echo "Enter A number"
read n
while [$n -ge 1]
do
fact=`expr $fact\ $n`
n=`expr $n-1`
done
echo "The Factorial Is $Fact"
This are some of the basic examples.For more shell script examples bookmark us.For more contents like our facebook page.
This Linux command may also useful
-
howto4 years ago
How To Manage Notification In Windows 10
-
howto3 years ago
How To Download Youtube Videos For Free
-
VPN2 years ago
What is VPN?
-
linux2 years ago
Best Linux Distro For Gaming 2021
-
VPN2 years ago
Best VPN For Chrome in 2021 | Learn More
-
VPN2 years ago
Best Free VPN For Netflix To Watch Latest Shows
-
VPN2 years ago
Thunder VPN – Fast and Free VPN
-
mobile4 years ago
Samsung Galaxy S10,S10+ and S10e Price Announced In Indian |Pre Booking Is Available Now
Rocco
March 17, 2021 at 4:57 am
Very rapidly this web site will be famous amid all blog viewers,
due to it’s good articles
Best Fiji Kava
May 24, 2021 at 2:53 am
I used to be able to find good information from your blog posts.
air pollution can occur within your home: prevention is key
May 25, 2021 at 2:59 pm
I don’t even know the way I ended up right here, but I believed this submit was once great.
I do not realize who you’re but certainly you’re going to a well-known blogger
should you are not already 😉 Cheers!
best fiji Kava
May 25, 2021 at 9:24 pm
I am glad to be a visitant of this double dyed web site, regards for
this rare information!
Semi Truck Rodeo
May 26, 2021 at 12:52 am
Hey there! I realize this is somewhat off-topic
however I had to ask. Does operating a well-established blog like yours require a lot of work?
I’m completely new to writing a blog but I do write in my
journal on a daily basis. I’d like to start a blog so I will be able to share my own experience and feelings online.
Please let me know if you have any kind of recommendations or
tips for brand new aspiring bloggers. Thankyou!