Can anyone help me with this, please:
This code works as intended:
eval "$(date "+yr=%Y mh=%m dy=%d hr=%H mt=%M sd=%S")" echo "year=$yr ; month=$mh ; day=$dy ; hour=$hr ; minute=$mt ; second=$sd"
It gives output
year=2012 ; month=02 ; day=09 ; hour=14 ; minute=30 ; second=17
This code should work similarly:
eval "$(command time -f "real=%e user=%U system=%S" ls > /dev/null)" echo "real = $real ; user= $user ; system = $system"
But it gives output
real=0.00 user=0.00 system=0.00 real = ; user= ; system =
Variables are not populated for some reason.
The only difference I could spot is that the first line
real=0.00 user=0.00 system=0.00 (coming from
time ) goes to stderr unlike output from
date that goes to stdout and isn't even printed. So I changed the script:
eval "$( (command time -f "real=%e user=%U system=%S" ls > /dev/null)>&1 )" echo "real = $real ; user= $user ; system = $system"
but result was same.