if you use "$PWD" variable the assignment seems  redundant too:)

On 11/14/07, Mike Stroyan <[EMAIL PROTECTED]> wrote:
>
> On Wed, Nov 14, 2007 at 01:11:12PM +0800, 龙海涛 wrote:
> > it works.
> > 3x very much.
> >
> > On Tue, 2007-11-13 at 21:51 -0700, Bob Proulx wrote:
> >
> > > 龙海涛 wrote:
> > > > i want to store the current working dir to a variable, i write
> > >
> > > The most common way to save the present working directory to a
> > > variable would be to use the $(...) form.
> > >
> > >   test=$(pwd)
> > >   echo $test
>
> By the way, the variable "$PWD" has the same current directory value
> as "$(pwd)" .
> Assigning with
> test=$PWD
> can be quite a bit faster than using $(pwd) to execute the pwd builtin.
>
> $ s=$SECONDS;for (( i=1;i<10000;i++ )) ;do d=$(/bin/pwd);done;echo
> $(($SECONDS-$s))
> 23
> $ s=$SECONDS;for (( i=1;i<10000;i++ )) ;do d=$(pwd);done;echo
> $(($SECONDS-$s))
> 8
> $ s=$SECONDS;for (( i=1;i<10000;i++ )) ;do d=$PWD;done;echo
> $(($SECONDS-$s))
> 0
>
> The speed difference probably doesn't matter for most situations.
>
> --
> Mike Stroyan <[EMAIL PROTECTED]>
>
>
>

Reply via email to