本文介绍了扑输出重定向到一个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么不是阅读的文本文件。这里有什么更好的方式是我的code。
我试图使用读取一条线,但它似乎没有工作。
如果[$#-ne 1]
然后
writeusage
出口
科幻
your_path = .. /文件/ TEST1
test_path = .. / .. /公/ TEST1
file_input =$ 1
而读-r线
做
ARGS + =$行
完成< $ file_input
#输出重定向到一个文件名为text
$ test_path> correctanswer 2 - ;&放大器; 1
#您重定向输出到文件名为文本2
$ your_path> youranswer 2 - ;&放大器; 1
#差异的解决方案
差异correctanswer youranswer
解决方案
(($#== 1))|| {writeusage; 1号出口; }your_path = .. /文件/ TEST1
test_path = .. / .. /公/ TEST1
file_input =$ 1#对于bash比4.x的年长
而读-r线;做
ARGS + =($线)
完成< $ file_input## ...较新的bash中,你可以这样做,而不是:
#readarray -t ARGS<$ file_input#输出重定向到一个文件名为text
$ test_path$ {ARGS [@]}> correctanswer 2 - ;&放大器; 1
#您重定向输出到文件名为文本2
$ your_path$ {ARGS [@]}> youranswer 2 - ;&放大器; 1
#差异的解决方案
差异correctanswer youranswer
Why isn't it reading the text file. What's a better way here is my code.I am trying to read a line using for but it doesnt seem to work
if [[ "$#" -ne 1 ]]
then
writeusage
exit
fi
your_path=../file/test1
test_path=../../public/test1
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
解决方案
(( $# == 1 )) || { writeusage; exit 1; }
your_path=../file/test1
test_path=../../public/test1
file_input="$1"
# for bash older than 4.x
while read -r line; do
args+=( "$line" )
done < "$file_input"
## ...for newer bash, you could do this instead:
# readarray -t args <"$file_input"
# Redirect the output to a file named text
"$test_path" "${args[@]}" > correctanswer 2>&1
# Redirect your output to a file named text2
"$your_path" "${args[@]}" > youranswer 2>&1
# diff the solutions
diff correctanswer youranswer
这篇关于扑输出重定向到一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!