diff --git a/script4.sh b/script4.sh new file mode 100755 index 0000000..061d702 --- /dev/null +++ b/script4.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +#this script is about navigatting directory levels +echo "" +LEVEL=$1 +echo "" + +#initialize CDIR to the current directory +CDIR="." + +#loop to move up the directory levels. +for ((i=1;i<=LEVEL;i++)); do + CDIR="../$CDIR" +done + + +#change to the calculated directory. +cd "$CDIR" || exit + +#print the current working directory. +echo "You are in: $PWD" + +#start new Bash session +exec /bin/bash