BigData-Shell

简介

本文用于日常练习使用

Shell

case-whenwhileiffor
如下样例:

#!/bin/bash
# case : bash case.sh start 1 1
#查询变量数目
echo "参数数目: $#"

#case-when
echo "case-when"
case $1 in
"io")
	for i in {0..3}
	do 
		 vmstat 1 1
	done
;;
*)
	echo "args is error!!!"
;;
esac

#while
echo "while"

num=$2
while [ $num -eq 1 ]
do 
	echo "$num==1"
	num=$[ num + 1 ]
done

# IF
echo "if"
if [ $3 -eq 2 ]
then
	echo "$3 is 2"
elif [ $3 -lt 2 ]
then 
	echo "$3 -lt 2"
else 
	echo "$3"
fi

echo "Bye Bye !!!"

两数相加:

#!/bin/bash

num1=$1
num2=$2

num3=$[ num1 + num2 ]
echo $num3
posted @ 2022-07-03 18:46  Anxc  阅读(33)  评论(0编辑  收藏  举报