使用shell批处理进行不同参数运算
2015-12-17 15:10
549 查看
<pre name="code" class="plain">#! /bin/sh Runjob(){ var1=$1 folder0="O`printf %0.2f $var1` " filelist="./Dat/grd_xy.grd ./Dat/Ivalue.plt ./Dat/ruvwt.p3d ./Dat/PSE_ZYM.inp" folder1="output" fileinp="PSE_ZYM.inp" varkey="Basis_ome_bat" jobcmd1="/localhome/zcb/20151217/Dat/Init_PSE.out >initial.log" jobcmd2="/localhome/zcb/20151217/Dat/PSE_v1.2_ext.out >PSE_run.log &" #Make dir folder0 ; ./ -> ./folder0 CMD="mkdir $folder0 ; cp $filelist $folder0 ; cd $folder0 ; mkdir $folder1" eval $CMD # awk 'pattern {action} pattern {action}' # '$varkey','$var1' when use variables of the shell '' is neccesary awk '/'$varkey'/{$3=“'$var1'”}1{print $0}' $fileinp > tmp ; mv tmp $fileinp echo $PWD eval $jobcmd1 eval $jobcmd2 cd .. } for var in `seq $1 $2 $3` do Runjob $var |tee -a run_jobs.log done
</pre><pre name="code" class="plain"><pre name="code" class="plain">collectfile(){ #folder name var1=$1 folder0=$2 filename0="Amp_PSE.plt" filename1="Bang_Amp_PSE.plt" info=$var1 #cd to output folder cd $var1 # check output folder if [ -d "output" ] ;then cd "output" #check if output file is ready if [ -f $filename0 ] ;then CMD="cp $filename0 $folder0/$var1-$filename0" eval $CMD info="$info Done..." fi if [ -f $filename1 ] ;then CMD="cp $filename1 $folder0/$var1-$filename0" eval $CMD info="$info Bang..." fi cd .. fi cd .. echo $info } folder0="/localhome/zcb/PSE_calc/Amp_check" #echo $folder0 CMD="mkdir -p $folder0" eval $CMD for var in `ls -d */` do var=${var%?} #cut the last character '/' collectfile $var $folder0 |tee -a $folder0/collect.log done
相关文章推荐
- shell小记:let
- bash的操作环境[转]
- 关于bash和dash
- Xshell使用教程及WinSCP使用教程
- shell脚本报错:-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory
- Shell变量:Shell变量的定义、删除变量、只读变量、变量类型
- Linux下Shell编程解析
- Linux下Shell编程解析
- Shell 编程快速入门
- shell 命令之 find命令二
- shell 命令之 find 命令一
- .bash_profile和.bashrc的区别
- shell入门
- 利用joomla 3.2.0 – 3.4.4 注入漏洞到getshell
- Shell 编程快速入门
- Linux下Shell编程解析
- Shell变量:Shell变量的定义、删除变量、只读变量、变量类型
- linux下使用Shell显示运行脚本进程号的方法
- Shell脚本中$的用法
- shell函数