【发布时间】:2014-04-24 22:16:34
【问题描述】:
我对 bash 脚本还很陌生,我坚持的部分是
done< "$file_input"
我想要实现的是当我在测试文件中运行程序时 ./test 包含
数字 15 14 90 22 和程序将把这些数字作为参数并运行它,但我很不确定如何做到这一点。我是否朝着正确的方向前进?
感谢您的帮助
if [[ "$#" -ne 1 ]]
then
writeusage
exit
fi
your_path=../file/test
test_path=../../public/test
file_input="$1"
while read -r line
do
args+="$line"
done < "$file_input"
------------------不确定如何将文本文件中的参数重定向到我的程序中,然后将结果放入名为正确答案的文件中并进行比较
# Redirect the output to a file named text
$test_path > correctanswer 2>&1
# Redirect your output to a file named text2
$your_path > youranswer 2>&1
# diff the solutions
diff correctanswer youranswer
【问题讨论】:
-
我问了一个新问题,因为那是一个不同的问题。
-
这个问题是一系列密切相关但不重复的问题之一:SO 23282867、SO 23281913、SO 23280857、SO 23280484。