我们在写一些功能性脚本的时候,往往会把操作相似或者参数类似行为接近的函数放在同一个shell脚本中,这样管理方便,维护简单,也很清晰。对于这种情况,通常的办法是,在shell脚本中定义所有用到的函数,然后在正文代码中用case语句读入输入的命令函数参数来调用指定的相应函数。这样就达到一个shell脚本使用的强大功能。
下面以一个简单的例子来说明。一个计算器提供了加减乘除的功能:
#!/bin/...
分类:
系统相关 时间:
2014-11-03 17:50:20
阅读次数:
278
1. 保护式(guard)中如果出错,不会报错,只会返回false!case 1=:1 of
true when not erlang:length(t) =:= 1 orelse true ->
ok;
_ ->
error
end.Result is: error保护式中对t (atom) 求length会出错,本应crash...
分类:
其他好文 时间:
2014-11-03 17:45:47
阅读次数:
410
表数据为:
CREATETABLEIT_research(deptnonumber,enamevarchar2(20));
INSERTINTOit_researchVALUES(100,‘HOPKINS‘);
INSERTINTOit_researchVALUES(100,‘JONES‘);
INSERTINTOit_researchVALUES(100,‘TONEY‘);
INSERTINTOit_researchVALUES(200,‘MORALES‘);
INSERTINTOit_resea..
分类:
其他好文 时间:
2014-11-03 16:36:26
阅读次数:
114
不使用乘除法,for、while 、if、else、switch、case、以及A?B:C三元表达式
求1+2+3+...+n...
分类:
其他好文 时间:
2014-11-03 14:36:52
阅读次数:
221
引言shell,我们常常会用到,以其强大的功能,会帮助我们解决非常多棘手的问题。近期遇到一个问题,要跑非常多case,假设串行的执行,须要非常久。能不能让他们并行起来,但又不能全部case都并行执行呢?,由于全部case同一时候执行,机器会挂掉的。1,方式1比較直接的一种方式是,维护两个文件队列(*...
分类:
系统相关 时间:
2014-11-03 14:22:15
阅读次数:
280
You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb...
分类:
其他好文 时间:
2014-11-03 14:21:20
阅读次数:
145
Checking 'working-make'... ok.Checking 'case-sensitive-fs'... ok.Checking 'getopt'... ok.Checking 'fileutils'... ok.Checking 'working-gcc'... ok.Check...
分类:
其他好文 时间:
2014-11-03 01:19:36
阅读次数:
218
在gridview中的RowDataBound事件里面写 switch (e.Row.RowType) {case DataControlRowType.Header:e.Row.BackColor = Color.FromArgb(153, 0, 0);e.Row.ForeColor...
分类:
其他好文 时间:
2014-11-02 23:53:12
阅读次数:
206
DP水题
求从上到下走完,使所取得权值最小,并输出路径,若有多个满足,则输出靠右的
#include "stdio.h"
#include "string.h"
int inf=0x3f3f3f3f;
struct node
{
int x,y;
}dp[110][110];
int main()
{
int Case,ii,i,j,n,m,ans;
int...
分类:
其他好文 时间:
2014-11-02 19:42:33
阅读次数:
230
import UIKit/***枚举类型*/enum direction{ case North case Sourth case East case West}//不会被默认为整数类型var d = direction.Eastd = .Westswitch d{ c...
分类:
编程语言 时间:
2014-11-02 13:44:33
阅读次数:
182