编写一个文件changefile,内容如下:
echo ""
echo "Pls select the dir you want to go"
echo "-------------------------------------------------"
echo "1 : home"
echo "2 : tool"
echo "3 : download"
echo "4 : music"
echo "5 : home/tool"
echo "0 : just exit"
echo "-------------------------------------------------"
needContinue="true"
while [ "$needContinue" = "true" ]
do
read choice
echo ""
case "$choice" in
0) needContinue="false"
;;
1) cd ~
needContinue="false"
;;
2) cd ~/tool
needContinue="false"
;;
3) cd ~/download
needContinue="false"
;;
4) cd ~/music
needContinue="false"
;;
5) cd ~ &&
cd tool
needContinue="false"
;;
esac
done
echo ""
clear
ls
echo ""
保存后执行下面的命令:
source changefile
或者
. changefile
注意,符号'.' 和changefile中间有空格