#!/bin/bash
I=0
while [ $I -lt 10 ]; do
printf "\e[1;3%dm%3d\e[0m" `expr $I % 8` $I
I=`expr $I + 1`
done
echo ""
echo "------------------------------------"
I=0
while ((I < 10)); do
printf "\e[1;3%dm%3d\e[0m" $(($I % 8)) $I
((I++))
done
echo ""
测试结果
#!/bin/sh
i=0
while ((i < 5))
do
echo $i
((i ++))
done
echo $((300 + 100))
if ((100 > 100))
then
echo ok
else
echo error
fi
测试结果
#!/bin/sh
while read line
do
user=`echo $line | awk '{print $1}'`
pass= `echo $line | awk '{print $2}'`
id $user &>/dev/null
if [ $? -eq 0 ];then
echo "$user already exists"
else
useradd $user
echo "$pass | passwd --stdin $user &>/dev/null"
if [ $? -eq 0 ];then
echo "$user is created."
fi
fi
done < $1