摘要:
最近在学习shell编程,文中若有错误的地方还望各位批评指正。先来看一个简单的求和函数#!/bin/bash#a test about functionf_sum 7 8function f_sum(){ return $(($1+$2));}f_sum 3 5;total=$(... 阅读全文
posted @ 2015-07-10 21:48
江南一点雨
阅读(156)
评论(0)
推荐(0)
摘要:
1.case脚本:#!/bin/bash#a test about casecase $1 in "lenve") echo "input lenve";; "hello") echo "input hello";; [a-zA-Z]) echo "It's a le... 阅读全文
posted @ 2015-07-10 16:38
江南一点雨
阅读(211)
评论(0)
推荐(0)
摘要:
格式:test 测试条件字符串测试:注意空格:test str1 == str2 测试字符串是否相等test str1 != str2 测试字符串是否不相等test str1 测试字符串是否不为空test -n str1 测试字符串是否不为空test -z str1 测试字符串是否为... 阅读全文
posted @ 2015-07-10 15:49
江南一点雨
阅读(176)
评论(0)
推荐(0)
摘要:
在expr中加减乘除的使用,脚本如下:#!/bin/sh#a test about exprv1=`expr 5 + 6`echo "$v1"echo `expr 3 + 5`echo `expr 6 / 2`echo `expr 9 \* 5`echo `expr 9 - 6`运行... 阅读全文
posted @ 2015-07-10 14:59
江南一点雨
阅读(197)
评论(0)
推荐(0)
摘要:
手动输入一行字符串,并对其排序。 脚本如下:#!/bin/bash#a test about sortecho "please input a number list"read -a arrsfor((i=0;i<${#arrs[@]};i++)){ for((j=0;j<${#... 阅读全文
posted @ 2015-07-10 14:16
江南一点雨
阅读(384)
评论(0)
推荐(0)

浙公网安备 33010602011771号