pushd

pushd

 编辑

本词条缺少信息栏名片图,补充相关内容使词条更完整,还能快速升级,赶紧来编辑吧!

Pushd是Windows操作系统cmd下的一个命令,作用是保存当前目录以供 POPD 命令使用,然后改到指定的目录。

目录

  1. 微软解释
  2. Linux

微软解释

编辑

用法:PUSHD [path | ..]

path 指定要成为当前目录的目录。

如果命令扩展名被启用,除了一般驱动器号和路径,PUSHD
  命令还接受网络路径。如果指定了网络路径,PUSHD 将创建一个
  指向指定网络资源的临时驱动器号,然后再用刚定义的驱动器
  号改变当前的驱动器和目录。可以从 Z: 往下分配临时驱动器
  号,使用找到的第一个没有用过的驱动器号。

Linux

编辑

pushd使用示例: [1] 

如果希望在/usr/src和/etc/X11和/boot/grub之间切换,则可以在命令行下输入:

pushd /usr/src

pushd /etc/X11

pushd /boot/grub

然后输入dirs查看,事实上每次输入都会显示当前pushd堆栈中的内容。

可以看到显示三个路径:

/boot/grub/etc/X11 /usr/src

输入pushd,既可以在前两个路径之间相互切换。

如果想切换到最后一个(栈底)路径时 pushd +2即可。

其他详细参数看上面帮助。

与pushd想对应的是Popd。popd的作用就是把当前栈内的最顶部的目录弹出来,并且切换到下边的目录

### Windows Command Line `pushd` Usage The `pushd` command is used to save the current directory before changing to a new one. This allows users to easily navigate back using the complementary `popd` command. The syntax for this operation can be summarized as follows: #### Basic Syntax ```plaintext PUSHD path ``` Where `path` specifies either an absolute or relative location that becomes the active working directory after execution. When specifying network paths with `pushd`, it automatically creates temporary drive letters starting from Z: and moving backward through unused letters until reaching A:[^1]. For instance, executing commands like these would demonstrate typical usages: ```batch C:\> pushd C:\Program Files\MyApp\ C:\Program Files\MyApp> ``` This changes the present working directory while preserving the previous state on what's known internally within Windows as "the stack." Another example involving remote shares might look something along those lines below: ```batch C:\Users\User> pushd \\server\share Z:\> ``` Here, assuming no other drives are mapped at Z:, the system assigns this letter temporarily so long as the session persists or another mapping does not override it first[^2]. --related questions-- 1. What alternatives exist for managing directories without relying upon `pushd`? 2. How do environment variables interact when switching between folders via `pushd`? 3. Can multiple levels of directories be pushed onto the stack simultaneously? If yes, how? 4. Is there any performance impact associated with frequent use of `pushd` especially concerning network locations? 5. Are there equivalent functions available in PowerShell compared to traditional CMD utilities such as `pushd`?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值