Fork me on GitHub

bash feature

bash调用-启动文件-交互式shell-条件表达式-shell算术-别名-数组-目录栈-提示符控制-受限shell-posix模式

受限shell  bash --restricted  它用来建立一个环境,比标准shell能有更多的控制。

posix模式  bash --posix

 

pushd ,popd,dirs
这几个命令可以使得工作目录书签化,就是可以按照顺序向前或者是向后移动工作目录,压栈的动作可以保存工作目录列表。
对于那些对当前的工作目录没有进行硬编码,并且需要对当前的工作目录做灵活的变动的脚本来说,这是很有用的命令。
注意:内建的$DIRSTACK数组变量,这个变量可以在脚本内存取,并且他们保存了目录栈的内容。

#!/bin/bash
dir1=/usr/bin
dir2=/var/spool
pushd $dir1
echo "Now in directory `pwd`."
pushd $dir2
echo "Now in directory `pwd`."
echo "The top entry in the DIRSTACK array is $DIRSTACK."
popd
echo "Now in directory `pwd`."
popd
echo "Now in directory `pwd`."

posted on 2015-05-18 15:38  阳光-源泉  阅读(221)  评论(0编辑  收藏  举报

导航