比方说,我执行了名为a.py
的python程序,它会打印出以下内容:
2 3
3 4
4 5
,我想编写此多行输出,就像将每个输入文件的文件分开一样。 这是我到目前为止尝试过的:
for file in $1/*
do
case "$file" in
*".in") echo
fileformat="p"
echo "using $file"
outputfile="$file$fileformat"
data=$(python3 a.py $file)
result="$data"
echo "Write to $outputfile"
echo $result >> $outputfile
;;
*) ;;
esac
done
现在,我将所有内容写入了一行,而不是所需的多行输出:
2 3 3 4 4 5
我在做什么错了?