csh - `cd =-` 是什么意思?
问题描述
像往常一样,我打错了命令
[csh]$ cd -
并输入
[csh]% cd =-
令人惊讶的是,这奏效了!
问题:这里的等号(
=
)是什么意思?
解决方案
我认为它与目录堆栈有关,通常由pushd
and操作popd
。
在 csh 中,cd =(index)
从目录堆栈中拉出该索引的元素,并替换顶部元素(索引 0),这也是当前目录。
-
这里的索引是目录堆栈中的底部元素。或者,-
如果目录堆栈仅包含当前目录,则用于前一个目录,这意味着您popd
退出了所有目录,或者您根本没有使用pushd
。在这种情况下,cd =-
工作方式与cd -
.
以下是手册页的解释:
Directory stack substitution (+)
The directory stack is a list of directories, numbered from zero, used by the pushd, popd and dirs builtin commands (q.v.). dirs can
print, store in a file, restore and clear the directory stack at any time, and the savedirs and dirsfile shell variables can be set to
store the directory stack automatically on logout and restore it on login. The dirstack shell variable can be examined to see the
directory stack and set to put arbitrary directories into the directory stack.
The character ‘=’ followed by one or more digits expands to an entry in the directory stack. The special case ‘=-’ expands to the
last directory in the stack. For example,
> dirs -v
0 /usr/bin
1 /usr/spool/uucp
2 /usr/accts/sys
> echo =1
/usr/spool/uucp
> echo =0/calendar
/usr/bin/calendar
> echo =-
/usr/accts/sys
The noglob and nonomatch shell variables and the expand-glob editor command apply to directory stack as well as filename substitu-
tions.
推荐阅读
- python - Xpath - 具有包含文本值的表格的多个嵌套 div
- maven - 构建 Spring Boot 应用程序的 Docker 镜像文件
- javascript - Alexa Nodejs Skill - 第二个意图询问总是失败
- ant - 如何在ant脚本中编写while循环?
- powershell - 从字符串中提取文本到文档末尾
- sql - 如何连接来自同一张表但不同行的单元格?
- javascript - 测量通过 AJAX 呈现的页面的 DOM 内容加载时间
- android - 如果未在 onCreate 中声明,则不会出现 Listview
- reactjs - 使用 NGINX 的 React、Express (Graphql) 应用程序中的 SSL
- machine-learning - 线性回归:使用 ML 代替 MSE 的模型有区别吗?