Name

pushd

Synopsis

pushd name

pushd [options]

pushd

Description

The first form changes the working directory to name and adds it to the directory stack. The second form rotates the nth entry to the beginning, making it the working directory. (Entry numbers begin at 0.) With no arguments, pushd switches the first two entries and changes to the new current directory. The +n, -l, -n, and -v options behave the same as in popd. See also dirs and popd.

Examples

% dirs
/home/bob /usr
% pushd /etc           
                     Add /etc to directory stack
/etc /home/bob /usr
% pushd +2             
                     Switch to third directory
/usr /etc /home/bob
% pushd                
                     Switch top two directories
/etc /usr /home/bob
% popd                 
                     Discard current entry; go to next
/usr /home/bob

Get Linux in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.