7

我记得有一种方法可以执行cd命令,自动返回到上一个目录(没有显式的cd ...)。可能吗?

4

4 回答 4

15

如果只想返回上一个目录,可以使用cd -.

如果您需要更多的地方可以回去,请尝试pushd <dir>(而不是cd <dir>),然后您可以返回popd

于 2010-03-09T11:11:50.737 回答
4

成立!我可以将它作为子外壳执行。

嵌入在括号之间的命令列表作为子外壳运行。

来源:http ://tldp.org/LDP/abs/html/subshel​​ls.html

于 2010-03-09T11:08:47.290 回答
1

此外,pushd 和 popd 可以派上用场——它们代表对一堆目录位置的操作——允许您“回到过去”。

于 2010-03-09T11:10:29.053 回答
1

你也可以试试这个cdargs包。有教程

概括:

yum -y install compat-libstdc++-296
wget http://www.skamphausen.de/downloads/cdargs/cdargs-1.31-1.i386.rpm
rpm -ivh cdargs-1.31-1.i386.rpm
updatedb
source `locate cdargs-bash.sh`
# You can use any method you like for locating this file and running it
# Also, you need to put it in the ~/.bash_profile file to run it every time you log in
echo source `locate cdargs-bash.sh` >> ~/.bash_profile
cdb

标记一个目录并四处移动:

cd /etc/conf/httpd/ext/
mark apaconf
cd /usr/local/src/
cdb apaconf

查看其他命令的链接或搜索 Internet。

于 2011-01-18T10:38:50.483 回答