技术改变生活

博客园 首页 新随笔 联系 订阅 管理

2020年4月27日 #

摘要: 1 [root@localhost array]# cat function_locate.sh 2 #!/bin/bash 3 if [ $# -ne 3 ];then 4 echo "usage: `basename $0` part1 part2 part3" 5 exit 6 fi 7 8 阅读全文
posted @ 2020-04-27 23:02 小阿峰 阅读(226) 评论(0) 推荐(0) 编辑

摘要: 1 [root@localhost array]# cat for.sh 2 #!/bin/bash 3 for i 4 do 5 #echo abc 6 let sum+=$i 7 done 8 echo $sum 9 [root@localhost array]# sh for.sh 1 2 3 阅读全文
posted @ 2020-04-27 22:39 小阿峰 阅读(381) 评论(0) 推荐(0) 编辑

摘要: 1 [root@localhost array]# cat function_array.sh 2 #!/bin/bash 3 4 num=(2 3 4) 5 array() { 6 echo "all parameters: $*" 7 local newarray=(`echo $*`) #其中 阅读全文
posted @ 2020-04-27 21:32 小阿峰 阅读(614) 评论(0) 推荐(0) 编辑