shell读取文件参数

环境

csh

说明

通常我们需要使用使用shell脚本处理一些事务,每次调用shell都需要添加参数。
如果重复调用多次这个shell脚本,我们可以将参数存入指定文件,循环得到参数。

shell脚本(auto_run)

#!/bin/csh  -f

#set list file of parameter 
set parameterlst = "$1"

#loop execute run
set n=`wc -l <$parameterlst`
set i=1
while ($i <= $n)
   set line="`awk '{if (NR == $i) print}' $parameterlst`"
   ./run "${line}"  
   @ i ++
end

调用

auto_run test.lst

文件说明

  • run 将要运行的shell脚本
  • test.lst中存放run需要重复调用的参数
  • auto_run 上面建立的脚本
posted @ 2016-10-31 12:30  乔_木  阅读(3922)  评论(0编辑  收藏  举报