Mathematical Aspect of Linux Shell Programming – Part IV - Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee

Thursday, March 5, 2015

Mathematical Aspect of Linux Shell Programming – Part IV



Hello Everyone,

In this tutorial,

Let Us Create a Mathematical Aspect of Linux Shell Programming – Part IV

You Can also Configure in Redhat Linux, Ubuntu, Fedora, CentOS, LinuxMint, Oracle Linux, Cloud Linux.

Script 1: Additions
Script 2: Substraction
Script 3: Multiplication
Script 5: Table
Script 4: Division
Script 5: Table
Script 6: EvenOdd
Script 7: Factorial


Script 1: Additions

Step1 :-  touch Addition.sh                    --       (Create a file)

Step2 :-  vi Addition.sh                          --      (Editing a file & Save, Quit)

                      #!/bin/bash

                      echo “Enter the First Number: ”

                      read a

                      echo “Enter the Second Number: ”

                      read b

                      x=$(expr "$a" + "$b")

                      echo $a + $b = $x

Step3 :-  chmod 755 Addition.sh           --       (Permission giving)

Step4 :-  ./Addition.sh                            --       (Finally Run Script)

Script 2: Subtraction

Step1 :-  touch Substraction.sh                    --       (Create a file)

Step2 :-  vi  Substraction.sh                         --      (Editing a file & Save, Quit)

                      #!/bin/bash

echo “Enter the First Number: ”

read a

echo “Enter the Second Number: ”

read b

x=$(($a - $b))

echo $a - $b = $x

Step3 :-  chmod 755 Substraction.sh            --       (Permission giving)

Step4 :-  ./ Substraction.sh                            --       (Finally Run Script)

Script 3: Multiplication

Step1 :-  touch Multiplication.sh                    --       (Create a file)

Step2 :-  vi Multiplication.sh                          --      (Editing a file & Save, Quit)

 #!/bin/bash

echo “Enter the First Number: ”

read a

echo “Enter the Second Number: ”

read b

echo "$a * $b = $(expr $a \* $b)"

Step3 :-  chmod 755 Multiplication.sh           --       (Permission giving)

Step4 :-  ./ Multiplication.sh                           --       (Finally Run Script)


Script 4: Division

Step1 :-  touch Division.sh                    --       (Create a file)

Step2 :-  vi Division.sh                         --      (Editing a file & Save, Quit)

                      #!/bin/bash

                      echo “Enter the First Number: ”

                      read a

                      echo “Enter the Second Number: ”

                      read b

                      echo “$a / $b = $(expr  $a  /  $b)”

Step3 :-  chmod 755 Division.sh         --       (Permission giving)

Step4 :-  ./Division.sh                            --       (Finally Run Script)

Script 5: Table

Step1 :-  touch Table.sh                    --       (Create a file)

Step2 :-  vi Table.sh                          --      (Editing a file & Save, Quit)

                      #!/bin/bash

echo “Enter The Number upto which you want to Print Table: ”

read n

i=1

while [ $i -ne 10 ]

do

i=$(expr $i + 1)

table=$(expr $i \* $n)

echo $table

done

Step3 :-  chmod 755 Table.sh           --       (Permission giving)

Step4 :-  ./Table.sh                            --       (Finally Run Script)

 

   Script 6: EvenOdd

Step1 :-  touch EvenOdd.sh                    --       (Create a file)

Step2 :-  vi EvenOdd.sh                          --      (Editing a file & Save, Quit)

                  #!/bin/bash

echo "Enter The Number"

read n

num=$(expr $n % 2)

if [ $num -eq 0 ]

then

echo "is a Even Number"

else

echo "is a Odd Number"

fi

Step3 :-  chmod 755 EvenOdd.sh          --       (Permission giving)

Step4 :-  ./EvenOdd.sh                           --       (Finally Run Script)

Script 7: Factorial

Step1 :-  touch Factorial.sh                    --       (Create a file)

Step2 :-  vi Factorial.sh                          --       (Editing a file & Save, Quit)

                    #!/bin/bash

echo "Enter The Number"

read a

fact=1

while [ $a -ne 0 ]

do

fact=$(expr $fact \* $a)

a=$(expr $a - 1)

done

echo $fact

Step3 :-  chmod 755 Factorial.sh           --       (Permission giving)

Step4 :-  ./Factorial.sh                            --       (Finally Run Script)

NOTE :- For Any Clarification Please Below
 
Comment,
Like and
Share  us  and  help us to spread.

####--------------------------------------------------------------------------------------####
Website    :-   http://www.cloudnetwork.in
Twitter     :-   http://twitter.com/itcloudnet
Skype Id  :-   cloud.network1
E-Mail Id :-   itcloudnet@gmail.com
####----------------------------------------------------------------------------------------####                         
Thanking You
Hope U Like it........


Comment Policy We’re eager to see your comment. However, Please Keep in mind that all comments are moderated manually by our human reviewers according to our comment policy, and all the links are nofollow. Using Keywords in the name field area is forbidden. Let’s enjoy a personal and evocative conversation.