Menu

Showing posts with label Shell Scripting. Show all posts
Showing posts with label Shell Scripting. Show all posts

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