Command not found when trying to set a format for the time command

I am trying to get the time it takes to run a command, with the output in a specific format:

time -f "%E" ls -l

This is similar to the example in the man page (and on the online man page). However when I run this command I get:

-f: command not found

It appears as though the time command is not reading the -f as an argument, rather as the command I am trying to run.

How can I get the execution time for a command in a specific format?

2 Answers

This is because time is a bash builtin command - and the builtin doesn't support the options you're trying to use.

Try this, use the full path of time to skip the built-in and use the real one:

/usr/bin/time -f "%E" ls -l
0

Unfortunately, time is both a bash keyword and a program in /usr/bin. If you specify the full path to time like:

/usr/bin/time -f "%E" ls -l

You will get the output you were expecting.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like