Mam taki skrypcik mający porównać szybkości strumieni w c++:
#!/bin/bash
powt=1000000
main="int main(){"
petla=" for( int i = 0; i < $powt; i++ ) "
end=" return 0;}"
file=test.cpp
ofile=test.a
clear
echo -e "#include<iostream> \n$main $petla std::cout << i;$end" > $file
echo "std::cout bez sync_with_stdio(0)"
g++ -o $ofile $file -lm
# echo `time ./$ofile`
echo -e "#include<iostream> \n$main std::ios_base::sync_with_stdio(0); $petla std::cout << i;$end" > $file ;
echo -e "\nstd::cout z sync_with_stdio(0)"
g++ -o $ofile $file -lm
# echo `time ./$ofile`
echo -e "#include<cstdio> \n$main $petla printf(\"%d\", i);$end" > $file
g++ -o $ofile $file -lm
echo -e "\nprintf()"
# echo `time ./$ofile`
I chciał bym wyświetlić tylko wyniki time. Jak to zrobić?
PS
Dopiero zaczynam się uczyć Bash'a