linux directory to quickly switch the directory stack

**** New cdxx file

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

if [-z $ 1]; then # determines whether the string is empty
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

 

*** modify file attributes:

chmod 777 cdxx

 

*** The files in a directory under PATH: / usr / local / bin

 

 

cp cdxx /usr/local/bin/

 

*** bashrc modify files in the current user:

 

 

 

 

**** test command:

 

 

note:

To execute a command in the current shell, need to use source execute the command.

 

Guess you like

Origin www.cnblogs.com/20170722-kong/p/12129407.html