shell 参数解析
2019-10-30 本文已影响0人
嘟嘟_runing
shell如何向c一样解析参数?可以使用shift命令,如下:
while [ $# -ge 3 ]
do
if [ $1 = "--ip" ]; then
ip=$2
shift 2
elif [ $1 = "--port" ]; then
port=$2
shift 2
else
echo "invalid parameter
fi
done
shell如何向c一样解析参数?可以使用shift命令,如下:
while [ $# -ge 3 ]
do
if [ $1 = "--ip" ]; then
ip=$2
shift 2
elif [ $1 = "--port" ]; then
port=$2
shift 2
else
echo "invalid parameter
fi
done