1
  1. popd

    Remove the top entry from the directory stack, and cd to the new top directory. When no arguments are given, popd removes the top directory from the stack and performs a cd to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; that is, popd is equivalent to popd +0.

    -n
    Suppresses the normal change of directory when removing directories from the stack, so that only the stack is manipulated.

    /home/t$ dirs -v
     0  ~
     1  /tmp
     2  ~/mydata
    /home/t$ popd -n
    ~ ~/mydata
    /home/t$ dirs -v
     0  ~
     1  ~/mydata
    

    Why not:

    /home/t$ dirs -v
     0  /tmp
     1  ~/mydata
    
  2. pushd

    Options:

     -n     Suppresses the normal change of directory when adding
            directories to the stack, so only the stack is manipulated.
    

    Arguments:

     +N     Rotates the stack so that the Nth directory (counting
            from the left of the list shown by `dirs', starting with
            zero) is at the top.
    
     -N     Rotates the stack so that the Nth directory (counting
            from the right of the list shown by `dirs', starting with
            zero) is at the top.
    

     dir    Adds DIR to the directory stack at the top, making it the
            new current working directory.

    /tmp$ dirs -v
     0  /tmp
     1  ~
     2  ~/mydata
    /tmp$ pushd -n +1
    /tmp$ dirs -v
     0  /tmp
     1  ~/mydata
     2  /tmp
    

    why not:

    /tmp$ dirs -v
     0  ~
     1  ~/mydata
     2  /tmp
    

    or

    /tmp$ dirs -v 0 /tmp 1 ~ 2 ~/mydata
0

It is pretty obvious what -n does: It doesn't change the stack at index 0.

Index 0 is always the $PWD (or pwd) and is not changed if option -n is used.

That is: popd or pushd will not execute a cd.

For other issues raise a new question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.