[ale] cd in bash or ksh, how to do this

Narahari 'n' Savitha savithari at gmail.com
Wed Sep 22 16:06:26 EDT 2010


Can  you take  and sec and explain what this is doing.

I dont see any ref to the ced func you wrote earlier.

On Wed, Sep 22, 2010 at 2:09 PM, Richard Bronosky <Richard at bronosky.com>wrote:

> 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 #!.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20100922/8e55c72a/attachment.html 


More information about the Ale mailing list