Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

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
share|improve this answer
    
ah ha! Tricky, tricky. That does it, thanks. –  Isaac Dec 8 '11 at 16:55

Unfortunately, time is both a bash keyword and a program in /usr/bin. If you specify the full path to time, as in /usr/bin/time -f "%E" ls -l you will get the output you were expecting.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.