1、服务端终止后重新启动
服务端死亡就再次启动一次,并记录启动次数
可替换
# cat /etc/passwd | awk -F: '$1=="root"{print $0}'
#!/sys/bin/sh
count=0
result=`ps | grep com.android.browser | busybox awk '{print $8}'`
echo $result
if [[ "$result" != "S" ]]
then
echo "正常"
else
echo "再次启动服务端"
count ++
echo $count
fi
shell终将命令结果传给变量
var=`command`
var=$(command)
用shell判断字符串中是否含有某特定字符串
strA="long string"
strB="string"
result=$(echo $strA | grep "${strB}")
if [[ "$result" != "" ]]
then
echo "包含"
else
echo "不包含"
fi
strB="string"
result=$(echo $strA | grep "${strB}")
if [[ "$result" != "" ]]
then
echo "包含"
else
echo "不包含"
fi
########
strA="helloworld"
strB="low"
if [[ $strA =~ $strB ]]
then
echo "包含"
else
echo "不包含"
fi
strB="low"
if [[ $strA =~ $strB ]]
then
echo "包含"
else
echo "不包含"
fi
#########
A="helloworld"
B="low"
if [[ $A == *$B* ]]
then
echo "包含"
else
echo "不包含"
fi
B="low"
if [[ $A == *$B* ]]
then
echo "包含"
else
echo "不包含"
fi