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
本文标题:shell 参数解析
本文链接:https://www.haomeiwen.com/subject/ajuavctx.html
网友评论