I have a very basic shell script here:
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
calculates some PSNR values and writes a detailed summary to a file for each combination of file
, qp
and i
. That's fine.
The 2>>
outputs one line of information that I really need. But when executed, I get:
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
What I want, however, is this:
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
How can I achieve that?
(Please feel free to change the title if you think there's a more appropriate one)
Like I would do in OCAML. How can I execute multiple commands in one like in python? You can just use semicolons.
If you want to execute all the commands, whether the previous one executes or not, you can use semicolon (;) to separate the commands. If you want to execute the next command only if the previous command succeeds, then you can use && to separate the commands.
You could pass the -n
option to your first echo
command, so it doesn't output a newline.
As a quick demonstration, this :
echo "test : " ; echo "blah"
will get you :
test : blah
With a newline between the two outputs.
While this, with a -n
for the first echo
:
echo -n "test : " ; echo "blah"
will get you the following output :
test : blah
Without any newline between the two output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With