Once upon a time Dave Wreski wrote:
> 
> 
> >     Anyway, could somebody explain what pushd
> >     and popd functions, I didn't really
> >     understand what stack ( tcsh man page ).
> >     I also saw these functions in a couple of PERL
> >     scripts, but I couldn't figure out what
> >     they did.
> 
> It is used to save the current directory.  Not generally very useful,
> unless you don't currently know what directory your in.  So, use `pushd'
> to push the current directory onto the stack, and use `popd' to `cd' back
> to the directory you pushed.

And the dirs command lists all the directories you have stacked up.

Actually this should be useful if you care, say, copying files between
directories with horribly long paths.

You could then do something like:

        cd /horribly/long/path/number/1
and then
        pushd /other/awful/path/which/I/dont/want/to/keep/typing

Now the command
        dirs +0
will print the most recent directory, and therefore

        cp * `dirs +0`

will copy everything from

/other/awful/path/which/I/dont/want/to/keep/typing 

to

/horribly/long/path/number/1

Unfortunatey there is a problem with bash recognising (or rather, not
recognising) the tilde (~) construct when enclosed in backquotes.

For example, if you're in your home directory and you:

        pushd fred

the result of 

        dirs +0

is simply:
        ~

Unfortunatley if you try, say:

        ls `dirs +0`

you get ~ not found.....
-- 
|Deryk Barker, Computer Science Dept. | Music does not have to be understood|
|Camosun College, Victoria, BC, Canada| It has to be listened to.           |
|email: [EMAIL PROTECTED]         |                                     |
|phone: +1 250 370 4452               |         Hermann Scherchen.          |


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to