Menu

Nested if else in Bash Shell scripting

Today in this tutorial we will see how to write if else and nested if else in Bash Shell scripting.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Program in Bash Shell

CHECK_SOURCE="[main] INFO com.dobe.jcr.checknode.existence.App - Node  exists"

echo $CHECK_SOURCE | grep -w -o -i 'Node exists'

if [ $? == 0 ]; then

    echo " Node Exists"

    echo $CHECK_SOURCE | grep -w -o -i 'checknode'

    if [ $? == 0 ]; then

        echo "checknode exist"

        echo $CHECK_SOURCE | grep -w -o -i 'adobe'

            if [ $? == 0  ]; then

                echo "Adobe exist"

            else

                echo "Adobe doesnot Exist"

            fi

    else

        echo "checknode doesnot Exist"

    fi

else

    echo "Node doesnot Exists"

fi

You may download the raw from Gist: https://gist.github.com/RashidJorvee/9e9de5c6f8fd2303d0438b492ee9ad33

4 comments:

  1. Are you suffering from problems in your life? Do you think that your life is not running easily and is not going in the direction it should? If yes then it is the right time to contact the best astrologer Pandit Raj who offers well known astrological solutions for all kinds of issues irrespective of the level of complication. Contact the expert Indian astrologer in Melbourne now and say bye to all issues related to astrology and say welcome to a new life.

    Best Astrologer in Melbourne

    ReplyDelete