2016年12月10日

Shell脚本判断是否是闰年

摘要: #! /bin/bash echo -n Input year to judge if it is a leap year: read year let "y1=$year % 4" let "y2=$year % 100" let "y3=$year % 400" if [ ! "$y1" -eq 0 ] then leap=0 elif [ ! "$y2" -eq 0 ] then leap... 阅读全文

posted @ 2016-12-10 20:06 leonardhelloworld 阅读(4427) 评论(0) 推荐(1) 编辑

shell脚本之使用bc工具实现数值转换(浮点转二进制)

摘要: #! /bin/bash echo -n input float: read num echo power of the operation: echo $num^2 |bc echo converted to binary echo "obase=2;$num" |bc [root@lenny Desktop]# ./zhuanhuan.sh input float:3.1415... 阅读全文

posted @ 2016-12-10 12:51 leonardhelloworld 阅读(854) 评论(0) 推荐(0) 编辑

shell脚本之函数的参数

摘要: #! /bin/bash echo use function hello() { echo how many parameters in the function:$#; echo the name of this function is $0; echo the first parameters is :$1; echo the second parameters is :$2; } hel... 阅读全文

posted @ 2016-12-10 12:13 leonardhelloworld 阅读(6951) 评论(0) 推荐(0) 编辑

shell脚本之while

摘要: #! /bin/bash echo if num smaller than 5,it will continue num=0 while [ $num -lt 5 ] do echo now the num is $num let num++ done [root@lenny Desktop]# ./while.sh if num smaller than 5,it will c... 阅读全文

posted @ 2016-12-10 11:52 leonardhelloworld 阅读(211) 评论(0) 推荐(0) 编辑

shell脚本之for循环

摘要: #! /bin/bash echo what programming lanuages do you know? for i in python C# java ruby perl do echo i know : $i done [root@lenny Desktop]# ./for.sh what programming lanuages do you know? i kno... 阅读全文

posted @ 2016-12-10 11:41 leonardhelloworld 阅读(317) 评论(0) 推荐(0) 编辑

导航