shell 基本语法测试

来源:互联网 发布:天津seo网络优化公司 编辑:程序博客网 时间:2024/04/28 20:53
#! /bin/bash


if_find_file(){
if [ -e /home/allen/test/shell_test/echo.sh ]
then
echo "file exit......"
else
echo " can't find this file......"
fi
}


if_find_eth0(){
#ifconfig | grep ppp0 
ifconfig | grep eth0 >> /dev/null 
if [ "$?" == "0" ]
then
echo "find etho......"  
else
echo "Don't find eth0......" 
fi
}


while_print_hello(){
count=0
while [ $count -le 2 ]
do
echo "hello......"
#((count++))
let "count+=1"
sleep 0.01
done
}


for_print_num(){
for x in one two three
do
echo $x
sleep 1
done
for num in $(seq 1 3)
do
echo $num
sleep 0.000000001
done
}


main(){
# [ ! -e /home/allen/test/shell_test/echo.sh ] && { echo have file 
#} 
[ -e /home/allen/test/shell_test/echo.sh ] && { echo have file;} 
# if_find_file
# if_find_eth0
# while_print_hello
# for_print_num
}


main
0 0
原创粉丝点击