Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ct {
- local cd_path="$( pwd )"
- local flag=""
- if [ $# -eq 0 ]; then
- echo "You must supply a directory name"
- return
- fi
- while [ -z ${flag} ]; do
- if [ $( basename "${cd_path}" ) = "${1}" ]; then
- flag="yes"
- else
- cd_path="$( dirname "${cd_path}" )"
- if [ "${cd_path}" = "/" ]; then
- flag="no"
- fi
- fi
- done
- if [ ${flag} = "yes" ]; then
- cd "${cd_path}"
- if [ -n "${2}" ]; then
- cd "${2}"
- fi
- else
- echo "'${1}' not found in working directory path"
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement