Snippet: Logging command time in scripts
- john
- March 22, 2025
This is a helpful bash function to print a command and the time taken.
Note that we need to explicitly use /usr/bin/time
to avoid calling the bash built-in time
.
time_debug() {
# output the command and real time taken
/usr/bin/time -f "%C # %e seconds" "$@"
}