我有一个可执行文件(语法),它在运行时从终端获取输入(事实),并在结束时按Ctrl+D (EOF)。在此之后,程序再次开始接受另一个输入(查询),最后我按下Ctrl+D,所以我要做的是从文件中输入事实,从终端中进行查询。我试过了
./grammer < facts.pl #this assumes that all the input is from file so program terminates after inputting only facts
cat facts.pl queries.pl | ./grammer #this merges both file and removes the EOF in between files
我可以按顺序输入多个文件吗?例如,在结束时,它首先执行eof,然后开始从file2获取输入?
我可以在文件结束前输入EOF吗?
发布于 2013-03-28 20:23:26
cat
是concatenate
的缩写,所以两个输入文件之间的区别当然就没有了。如果./grammer
无法通过将文件名作为参数传递来读取文件目录
./grammer facts.pl queries.pl
您需要为每个文件分别调用./grammer
。
for f in facts.pl queries.pl; do
./grammer < "$f"
done
https://stackoverflow.com/questions/15681035
复制相似问题