linux 目录快速切换 目录栈

**** 新建cdxx 文件

#echo "Input something:"
#read input
#echo "Your input is: $input"
#kong=$input
#echo ${kong:0:1}

if [ -z $1 ];then #判断字符串是否为空
echo "in parameter"
exit 9
fi


#if [-z $2];then
# args3=$2
#fi

case $1 in
-v)
dirs -v
;;
-c)
dirs -c
echo "dirs -c"
;;
-s)
if [ -z $2 ];then
echo "argument error"
exit 9
fi
args3=$2
args3_1=${args3:0:1}
if [ "$args3_1" = "+" ];then
args3_2=${args3:1}
#echo "$args3_2"
# pushd $2 > /dev/null
elif [ "$args3_1" = "-" ];then
args3_2=${args3:0}
#echo "$args3_2"
# pushd $2 > /dev/null
fi

pushd $2 > /dev/null
;;
-d)
if [ -z $2 ];then
echo "argument error"
exit 9
fi
#echo "other"
popd $2 > /dev/null
;;
*)
echo "argument error"
esac

*** 修改文件的属性:

chmod 777 cdxx

*** 将文件放入PATH的某一个目录下:/usr/local/bin

cp cdxx /usr/local/bin/

*** 修改当前用户下的bashrc 文件:

 

**** 测试命令:

注意:

要在当前shell 下执行命令,需要使用source 执行命令。

猜你喜欢

转载自www.cnblogs.com/20170722-kong/p/12129407.html
今日推荐