shell script 脚本传递参数的方法
2013-10-14 03:57
507 查看
shell 脚本中传递参数3种方法的比较
By reading from a configuration file:
Bash里使用getopts解析非选项参数
在Shell脚本中处理命令行参数By reading from a configuration file:
PINTOOL obj-ia32/cacheSim3.so mode 0 nL1 16 nL1Set 256 nBlockPerL1Set 1 nL2 1 nL2Set 16384 nBlockPerL2Set 16 nStoreBuffer 64 emitTrace 0 coherenceMode D L1Latency 2 L2Latency 10 MemoryLatency 300
#!/bin/sh if [ $# -lt 1 ]; then echo "Usage: $0 <configure>" exit fi ################################################ # Pin Parameters, read from configuration file ################################################ while read line do #echo $line key=`echo $line |awk {'print $1'}` val=`echo $line |awk {'print $2'}` echo $key $val case "$key" in PINTOOL) PINTOOL=$val;; mode) mode=$val;; nL1) nL1=$val;; nL1Set) nL1Set=$val;; nBlockPerL1Set) nBlockPerL1Set=$val;; nL2) nL2=$val;; nL2Set) nL2Set=$val;; nBlockPerL2Set) nBlockPerL2Set=$val;; nStoreBuffer) nStoreBuffer=$val;; emitTrace) emitTrace=$val;; coherenceMode) coherenceMode=$val;; L1Latency) L1Latency=$val;; L2Latency) L2Latency=$val;; MemoryLatency) MemoryLatency=$val;; *) echo "Sorry, $key not recognized ..." exit 1;; esac done < $1 RunCacheCore="pin -t $PINTOOL -l1c $nL1 -l1s $nL1Set -l1b $nBlockPerL1Set -l2c $nL2 -l2s $nL2Set -l2b $nBlockPerL2Set -sbd $nStoreBuffer -trace $emitTrace -coh $coherenceMode -l1lat $L1Latency -l2lat $L2Latency -memlat $MemoryLatency" ################################# # Global Application Parameters ################################# RESULTS=results [[ ! -d $RESULTS ]] && mkdir -p $RESULTS np=4
相关文章推荐
- shell中使用ftp登陆服务器get文件
- shell 随机密码
- 在shell中使用expect+ssh登陆远程服务器
- 使用shell关闭占用某一个端口的程序
- Ubuntu的shell之bash和dash
- 直接插入排序、折半插入排序、shell插入排序
- 直接插入排序、折半插入排序、shell插入排序
- 转shell中的awk用法详解
- WF4.0 基础篇 (二十八) WF调用PowerShell
- linux bash_profile和.bashrc区别
- 常见web中间件拿shell
- linux 使用文本编辑器编写shell脚本执行权限不够
- Linux的经典shell命令整理
- bash中的配置文件
- shell使用echo输出个性字体
- shell脚本删除旧日志文件
- Android shell中特有命令
- shell 抓取网页解析网页 自动读取poj测试数据
- bash脚本写文本文件
- bash脚本函数中无法访问脚本参数的问题