I have the following functions in my ~/.bash_aliases file
mycd() {
dir=$(cat)
echo "$dir"
cd "$dir"
}
alias c=mycd
and
gotoD() {
find -name $1 -type $2 | awk '{ print $0 }' | sort -k2 | head -1 | c
}
alias goto=gotoD
I want to be able to type
goto directory_name d
and have the functions search for the directory and cd into the nearest one The problem is that though the found path to the directory gets into mycd, it is unable to actually change directories and simple remains in the same directory without any errors.
Any help would be greatly appreciated.
Thanks