我这里有一个非常基本的shell脚本:

for file in Alt_moabit Book_arrival Door_flowers Leaving_laptop
do
    for qp in 10 12 15 19 22 25 32 39 45 60
    do
        for i in 0 1
        do
            echo "$file\t$qp\t$i" >> psnr.txt
            ./command > $file-$qp-psnr.txt 2>> psnr.txt
        done
    done
done

command计算一些PSNR值,并将fileqpi的每个组合的详细摘要写入文件。没关系。
2>>输出我真正需要的一行信息。但当被处决时,我得到:
Alt_moabit  10  0
total   47,8221 50,6329 50,1031
Alt_moabit  10  1
total   47,8408 49,9973 49,8197
Alt_moabit  12  0
total   47,0665 50,1457 49,6755
Alt_moabit  12  1
total   47,1193 49,4284 49,3476

不过,我想要的是:
Alt_moabit  10  0    total  47,8221 50,6329 50,1031
Alt_moabit  10  1    total  47,8408 49,9973 49,8197
Alt_moabit  12  0    total  47,0665 50,1457 49,6755
Alt_moabit  12  1    total  47,1193 49,4284 49,3476

我怎样才能做到?
(如果您认为有更合适的标题,请随意更改标题)

最佳答案

echo实用程序的(GNU版本)有一个-n选项来省略后面的换行符。在你的第一个回音上用这个。为了便于阅读,您可能需要在第一行之后或第二行之前留出一些空间。

10-06 08:17
查看更多