If I want to time the running of rsync by time rsync -a /media/t/1/  ./, after it finishes, does $? report the exit value for time not for rsync? How can I both time rsync and get its exit value?
Both time `rsync` and get its exit value?
rsync;time
Bash's built-in time returns the exit status of the command. You can test that fairly easily with time false; afterwards, echo $? prints 1 as expected. You can also test something with a different exit code to confirm other codes are preserved:$ time bash -c 'exit 42'; echo Exit code: $?real    0m0.002suser    0m0.000ssys     0m0.000sExit code: 42