[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] cd in bash or ksh, how to do this
However, if you insist on making a cd replacement with that interface,
simplify it down to:
function cd () {
if [ -n "$2" ] ; then
?builtin ?cd "${PWD/foo/bar}"
else
?builtin cd "$@"
fi
}
BTW, quoting is important! Directory names do often have spaces. So,
my previous reply should have been:
function ced () { nd="$(pwd | sed "$@")" && cd "$nd"; }
>> function cd () {
>> ?if [ -n "$2" ] ; then
>> ? ?nd=`pwd | sed 's/'$1'/'$2'/'`
>> ? ?builtin ?cd $nd
>> ?else
>> ? ?builtin cd $1
>> ?fi
>> }
>>
>> bash$ cd /usr/lib/
>> bash$ pwd
>> /usr/lib
>> bash$ cd usr var
>> bash$ pwd
>> /var/lib
--
.!# RichardBronosky #!.