declare -i s
for(( i=1; i<=100; i=i+1))
do
s=s+i
done
echo "The count is --> $s"
[dev@abtsvr shellTest]$ sh test8.sh
The count is --> 5050
---------------------------------
declare -i s
declare -i i
while [ "$i" != "101" ]
do
s=s+i
i=i+1
done
echo "The count is --> $s"
----------------------------------------
declare -i s
declare -i i
until[ "$i" = "101" ]
do
s=s+i
i=i+1
done
echo "The count is --> $s"
----------------------------------------
list="qsd qqq qddd qdsss"
for i in $list
do
echo $i
done
[dev@abtsvr shellTest]$ sh test8.sh
qsd
qqq
qddd
qdsss
------------------------------------------
account='cut -d ":" -f1 /etc/passwd|sort'
echo "The following is your linux server's account"
for i in $account
do
echo $i
done
[dev@abtsvr shellTest]$ sh test8.sh
The following is your linux server's account
cut
-d
":"
-f1
/etc/passwd|sort 、、、、、、、、、、、、、、输出有误!!!!!!!???????????
----------------------------------------------
if [ ! -e logical ]; then
touch logical
echo "just make a file logical"
elif [ -e logical ] && [ -f logical ]; then
rm logical
mkdir logical
echo "remove file -->logical"
echo "and make directory logical"
exit 1
elif [ -e logical ] && [ -d logical ]; then
rm -rf logical
echo "remove directory -->logical"
exit 1
else
echo "does here have anything ?"
fi
--------------------------------
[dev@abtsvr shellTest]$ vi test11.sh
hello="hello!how are you "
echo $hello
hello! how are you
~
~
~
"test11.sh" [新] 4L, 60C 已写入
[dev@abtsvr shellTest]$ sh test11.sh
hello!how are you
test11.sh: line 4: hello!: command not found
[dev@abtsvr shellTest]$ sh -n test11.sh
[dev@abtsvr shellTest]$ sh -v test11.sh
hello="hello!how are you "
echo $hello
hello!how are you
hello! how are you
test11.sh: line 4: hello!: command not found
[dev@abtsvr shellTest]$ sh -x test11.sh
+ hello=hello!how are you
+ echo 'hello!how' are you
hello!how are you
+ 'hello!' how are you
test11.sh: line 4: hello!: command not found