# 记一次shell编写

需求

希望写一个脚本用来管理多个ssh ip
功能 xx.sh 1
ssh ip1
xx.sh 2
ssh ip2

实现

#!/bin/bash
echo "conneted"
echo $1
if [ 1 == "$1" ];then
    echo "connect product"
    ssh xxx
elif [ 2 == "$1" ];then
    echo "connect test"
    ssh xxxx
fi

问题1: if判断格式

问题2: 获取参数$0 -- $9 0代表命令本身,所以需要从1开始

猜你喜欢

转载自www.cnblogs.com/MagicalFool/p/12202341.html