How to change the path location within the shell script?

Hi ALL,

I am trying to find the installed tomcat version and location of the server.xml file to get the tomcat port number.

Using below script to do that.

#!/usr/bin/env bash

var1=$(find / -name "version.sh" ! -size 0 2>&1 |egrep -v "tmp|docker")

for loc1 in $var1
do
    abc=$(echo "$loc1" | rev | cut -c 11- | rev)
    tomcat_version=$(cd "$abc";./version.sh | grep "Server number:" | awk '{print $3}')
    tomcat_status=`tomcat`

    if [ "$tomcat_version" != "" ];then
    echo $tomcat_version
     echo "$abc"
     

    break
    fi
done

but in order to get the port number i want to change from tomcat/bin to tomcat/conf location.
For that i tried to use below synatx but it's not working.

echo "$(cd "$abc";../..)"

Can someone please suggest how to change the path?

You can let the system go in then two levels out

echo "$abc/../.."

Or strip two levels from the end of the pathname (this is a pure string manipulation)

echo "${abc%/*/*}"