Here’s what I am trying to do:
time sh -c "dd if=/dev/zero of=ddfile bs=512 count=125 && sync"
When run that on shell the o/p is
125+0 records in
125+0 records out
64000 bytes (62.5KB) copied, 0.028935 seconds, 2.1MB/s
real 0m 0.08s
user 0m 0.00s
sys 0m 0.01s
I want to capture the output to a variable or to a file. How do I do that ?
Thanks!
You can do:
Since you need to redirect the output of both
timeandddyou need to enclose the entire thing in(..).Both
timeandddsend their output to stderr, so using>will not work, you need2>which redirects stderr.To get the output in a variable you can do: