Check out example codes for "linux strip foldder name from path". It will help you in understanding the concepts better.

Code Example 1

FILE="/home/vivek/lighttpd.tar.gz"
basename "$FILE"
f="$(basename -- $FILE)"
echo "$f"

Learn ReactJs, React Native from akashmittal.com