If I run time uname -a | awk '{ print substr($3,1,9)" "$12 }'
, I get:
$ time uname -a | awk '{ print substr($3,1,9)" "$12 }'
4.15.0-70 x86_64
real 0m0.016s
user 0m0.003s
sys 0m0.016s
$
I would like to run the above command several times and save the entire output to a file. So I tried
for i in {1..10}; do time uname -a | \
awk '{ print substr($3,1,9)" "$12 }' >> uname.txt; done
But only 4.15.0-70 x86_64
is sent ten times to the file uname.txt
. The output of time
is sent to the screen for each run and not to uname.txt
.
So how can I have the output of time
also captured in uname.txt
?
I can use script
and that works but the output isn't pretty:
(B[m(B[m(B[m4.15.0-70 x86_64
real 0m0.017s
user 0m0.013s
sys 0m0.007s
(B[m(B[m(B[m4.15.0-70 x86_64
real 0m0.015s
user 0m0.008s
sys 0m0.009s
(B[m(B[m(B[m4.15.0-70 x86_64
real 0m0.015s
user 0m0.008s
sys 0m0.008s
Or as an image:
I know I could clean it up if there's no better way.
time
command; even alone, you won't get lines expected