文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>使用pushd保存路径

使用pushd保存路径

时间:2008-02-26  来源:ller

 pushd [-n] [dir]
       pushd [-n] [+n] [-n]
              Adds  a  directory to the top of the directory stack, or rotates
              the stack, making the new top of the stack the  current  working
              directory.  With no arguments, exchanges the top two directories
              and returns 0, unless the directory stack is empty.   Arguments,
              if supplied, have the following meanings:
              +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.
              -n     Suppresses  the  normal  change  of directory when adding
                     directories to the stack,  so  that  only  the  stack  is
                     manipulated.
              dir    Adds dir to the directory stack at the top, making it the
                     new current working directory.

              If the pushd command is successful, a dirs is performed as well.
              If  the first form is used, pushd returns 0 unless the cd to dir
              fails.  With the second form, pushd returns 0 unless the  direc-
              tory  stack  is empty, a non-existent directory stack element is
              specified, or the directory change to the specified new  current
              directory fails.

pushd and popd are also used for changing directories. pushd is like cd, but it also pushes the cwd onto a stack before changing directories. popd pops the top of the stack and returns you to the previous directory. For example:
$ pwd
/home/fred/csclasses/chess
$ pushd /home/fred/stuff
$ pwd
/home/fred/stuff
$ popd
$ pwd
/home/fred/csclasses/chess
转自http://faculty.cs.byu.edu/~rodham/cs240/linux-tutorial/linuxdoc.html#history

[root@root /var]#pushd .(键入路径名即可)
[root@root /var]#dirs(显示堆栈信息)
/var
[root@root /home]#pushd .
/user/home /var (栈顶为左端,把新的路径压入堆栈栈顶)
[root@root /httpd]#pushd .
/user/home/httpd /user/home /var
[root@root /httpd]#pushd +1(旋转堆栈,来使用第二个路径)
/user/home /var /user/home/httpd
[root@root /httpd]#popd +1
/user/home /user/home/httpd(/var路径被删除)
转自http://www.cnblogs.com/shadowicool/articles/1055115.html
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载