作者mystea (mystea)
看板Linux
标题Re: [问题] 想写一个有点小复杂的linux script
时间Thu Oct 9 01:16:29 2008
※ 引述《liangjr (aaa)》之铭言:
: ※ 引述《mystea (mystea)》之铭言:
: : 各位好, 我想写一个bash script来重复跑一个叫做(./program)的程式.
: : ./program 本身会从一个叫做 input.txt 的档案读取输入资料(三个浮点数),
: : 然後进行运算产生结果.
: : 写script的目的是要让电脑自动去读不同的输入资料.
: : 比方说我总共要跑(./program) 25次. 第一次要输入1.0 3.5 4.2,
: : 第二次要输入6.8 7.1 5.3,....这样.
: : 这些不同的输入值被存在另一个档案input.list里:
: : #start of input.list:
: : 1.0 3.5 4.2
: : 6.8 7.1 5.3
: : ...
: : ...
: : ...
: : (共25行)
: : #end of input.list
: : 所以跑第一次的时候, 我要先让bash script读input.list的第一行,
: : 然後把第一行的结果存成input.txt, 然後执行./program
: : 执行完./program之後, 把input.txt洗掉, 进行第二个回圈. 第二个
: : 回圈要把input.list的第二行存成input.txt然後执行./program,...
: : 如此周而复始...
: : 请问我该从何下手呢? 感谢不尽.
: #!/bin/bash
: while read line
: do
: echo $line > "input.txt"
: ./program
: done < "input.list"
: 不过为啥不让program吃stdin就好了? 这样一直存取file很慢耶
谢谢. 这正是我想要的. :)
所以
while test-command
do
...
done<"input.list"
是定义成和
(
while test-command
do
...
done
)<"input.list"
一样罗??
至於program为何不吃stdin? 我也不知道. program不是我写的阿 XD
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 76.170.235.113