Shell中的函数调用的使用方法见我下面的代码示例:

#!/bin/bash

# value init

ExP="adb shell /data/local/tmp/vpxdec  --yv12 --flipuv  -t 2 --md5   data/local/tmp/vp9Input/subset_function_test/Boating_1920x1080_t4_yv12_400frames_skip200.webm";
TT="adb shell ls -l /data/local/tmp/";
loop_count=;
targetMd5="2e8698fe47dd40bf6260206416530985"; # Compare two value and output result,$ is src,$ is target
function Compare()
{
#echo "Source value:$1, Target value:$2";
if [ "$1" = "$2" ]; then
echo "The same!";
return ;
else
echo "Different!"
return ;
fi } # LoopEx: excute a programm in a loop, $ is program,$ is loop count, $ is targetMd5
function LoopEx()
{
local Ex=$;
local loop_count=$;
local target=$;
echo -e "Programm is $Ex \nloop_count ==$loop_count, TargetMd5==$target"
for i in $(seq $loop_count); do
local output=$($Ex);
local outputMd5=${output::}
Compare $outputMd5 $target;
if [ "$?" != "" ]; then
echo "Loop Break index is [$i],result MD5:$outputMd5"
break
fi
done;
} # function main, shell excute from here
function Main()
{
echo "Imagation GPU Version test run ...";
LoopEx "$ExP" $loop_count $targetMd5
} Main;

后面写其他的简单脚本可以套用这个模板来做

Shell编程之函数调用的更多相关文章

  1. Linux Shell编程入门

    从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...

  2. Linux下的Shell编程

    从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操 ...

  3. 转:Linux Shell编程入门

    http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html 从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来 ...

  4. Linux Shell编程参考大全

    本文记录Linux Shell编程中常用基本知识,方便快速入门以及查询使用. 本文主要分为以下几个部分: 一.Shell中的变量 任何编程语言中,有关变量的定义,作用范围,赋值等都是最最基础的知识. ...

  5. linux shell 编程参考

    #!/bin/bash my_fun() { echo "$#" } echo 'the number of parameter in "$@" is '$(m ...

  6. 转inux Shell编程入门

    http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html 从程序员的角度来看, Shell本身是一种用C语言编写的程序,从用户的角度来 ...

  7. Linux(五)shell编程基础

    一.Linux shell简介 1.shell概述 Shell 是用户与内核进行交互操作的一种接口,目前最流行的 Shell 称为 bash Shell          Shell 是一门编程语言& ...

  8. 2. Shell编程第二讲

    (1) 条件测试: test   [ 命令 test 或 [ 可以测试一个条件是否成立,如果测试结果为真,则该命令的Exit Status为0,如果测试结果为假,则命令的Exit Status为1(注 ...

  9. shell编程基础进阶

    为什么学习shell编程 shell脚本语言是实现linux/unix 系统管理机自动化运维所必备的重要工具,linux/unix系统的底层及基础应用软件的核心大部分涉及shell脚本的内容.每一个合 ...

随机推荐

  1. mod_wsgi

    配置: WSGIScriptAlias /var/www/wsgi-scripts/simple.wsgi def application(environ, start_response): outp ...

  2. GDI画验证码

    Random r = new Random(); string str = ""; for (int i = 0; i < 5; i++) { int a= r.Next(0 ...

  3. mac下Apache + MySql + PHP网站开发

    最近接了个小活,做一个使用PHP语言和MySql数据库的动态网站.之前做过类型的网站,是在windows系统下做的,开发环境使用的是 AppServ 的PHP开发套件.现在有了我的大MAC,所以找了M ...

  4. C#读取带命名空间的xml,xaml文件的解决方案

    使用C#读取xml文件有三种常用的方式: 1.xmlDocument 2.XmlTextReader 3.Linq To Xml 但是这些方式在读写有些带命名空间的xml时就不知道怎么办了(例如把xa ...

  5. 【转】mybatis在xml文件中处理大于号小于号的方法

    http://blog.csdn.net/zheng0518/article/details/10449549 第一种方法: 用了转义字符把>和<替换掉,然后就没有问题了. SELECT ...

  6. 【转】mybatis 获取自增id

    转自:http://www.cnblogs.com/rhythmK/p/4047142.html 1.环境: mybatis : 3.2.3 spring-mybatis:  1.2.1 mysql: ...

  7. C++语言十进制数,CDecimal(未完成)

    在C#和Java中都有存在decimal类似的十进制数字,C++中尚未发现,春节假期忙里抽闲写了一个玩玩,时间紧迫没有测试,只能保证编译通过.抛砖引玉,欢迎大家多提建议 当前缺陷: 1. 除法功能没有 ...

  8. SVN - 配置

    版本控制器 1.创建文件夹 svn 2.打开终端 进入该文件夹 3.输入 svnadmin 如果有错 xcrun: error: active developer path ("/Appli ...

  9. Memcached(一)在Windows上安装和测试memcached

    1)下载memcached的windows安装程序 memcached-1.2.4-Win32-Preview-20080309_bin.zip 或其他版本 2)解压memcached  用管理员身份 ...

  10. TCP/IP入门学习(1)---分层概述

    本文旨在记述一些学习中的笔记 OSI分层:应用层,表示层,会话层,传输层,网络层,数据链路层,物理层 详细点: 1.应用层:为应用程序提供服务并规定程序中通信相关细节. 2.表示层:将应用处理的信息转 ...