#!/bin/bash
echo "请输入:yes|no"
read command
if [ "$command" = "yes" ] || [ "$command" = "YES" ]; then
echo "yes..."
else
echo "no..."
fi
echo "请输入条件:if|elif|else"
read condition
if [ "$condition" = "if" ] ; then
echo "----if----"
elif [ "$condition" = "elif" ]; then
echo "----elif----"
else
echo "----else----"
fi
echo "请输入CASE:(A|B|C)";
read con
case $con in
A)
echo "AA";;
B)
echo "BB";;
C)
echo "C"
;;
*)
echo "请输入:A|B|C"
exit 1;
esac
echo "done...";
--------------------------------------------------------
#!/bin/bash
while read id name age
do
echo "id:${id} name:${name} age:${age}"
done < ./data
# 数据如下:
more data
1 zhangsan 50
2 lishi 30
#执行
sh test.sh
id:1 name:zhangsan age:50
id:2 name:lishi age:30
#!/bin/bash
x=0
# =
if [ "$x" -eq 0 ];
then
x=1;
echo "$x"
fi
# >
if [ "$x" -ge 1 ];
then
x=`expr $x + 1 `
echo "success 1---$x"
fi
if [ "$x" -ge 1 ];
then
echo "success 2--------$x"
fi
#<
while [ "$x" -lt 10 ];
do
y="$x"
echo "$x"
x=`expr $x + 1`
done