#!/bin/bash
#Program:
# This program shows "Hello World!" in your screen.
#History
# 2015/12/09
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#while
while [ "$yn" != "yes" -a "$yn" != "YES" ]
do
read -p "Please input yes/YES to stop this program : " yn
done
#until
until [ "$yn" == "yes" -o "$yn" == "YES" ]
do
read -p "Please input yes/YES to stop this program : " yn
done
#for
for obj in dog cat mourse
do
echo "name is : $obj"
done
names="zhangsan:lisi:zhaoliu:wangwu"
param=$(echo $names | sed 's/:/ /g')
for obj in $param
do
echo "name is : $obj"
done
for obj in $(seq 1 10)
do
echo "name is : $obj"
done
s=0
for((i=0;i<=100;i++))
do
s=$(($s+$i))
done
echo "sum is : $s"
##测试命令 sh [nvx] shn.sh
##n:不执行仅检查语法
##v:执行前打印到屏幕
##x:将使用到的代码显示到屏幕。执行一步显示一步,调试必备
Shell编程之循环_demo
最新推荐文章于 2024-08-13 10:15:11 发布