Fork me on GitHub

# 记一次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开始

posted @ 2020-01-16 17:17  MgicalFool  阅读(93)  评论(0编辑  收藏  举报