I\'m struggling to parse the output of the time command in bash - and even to stop it from printing out its output when I call it. This is my test code:
#!/b
If you use the Bash builtin time, you can control its output by setting the TIMEFORMAT variable:
TIMEFORMAT=%R
and you won't have to do any parsing since that will cause time to only output the number of seconds.
and use this:
echo "Testing..."
TIME=$( { time ls -lh > /dev/null; } 2>&1 )
echo $TIME
or one of the other techniques from BashFAQ/032.