Saturday, April 27, 2024
127
rated 0 times [  127] [ 0]  / answers: 1 / hits: 34524  / 1 Year ago, thu, november 17, 2022, 4:59:25

I tried to use time command with -f option to format the output of time, but I get the following error:



-f: command not found


Then I tried to use other options -a, -o, etc and I get the same error. Not even time --version doesn't work (--version: command not found).



Don't tell me to read the man because I already do it by many times... All these options are specified there. So, where could be the problem?


More From » command-line

 Answers
2

Well, even if you don't like it, I will put you to read again with more attention man time. At the end of EXAMPLES section you will find:


  Users of the bash shell need to use an explicit path in order to run
the external time command and not the shell builtin variant. On system
where time is installed in /usr/bin, the first example would become
/usr/bin/time wc /etc/hosts

So, I'm assuming that you use bash shell which uses an internal version of time, provided as a shell keyword. You can check this using the following command:


type time

and the output will probably be:


time is a shell keyword

If this is the case, then it is clear that to use the real time command you must use its explicit path: /usr/bin/time.


Further, if you don't want to use anymore the shell keyword time, you can create a permanent alias as follow:


alias time='/usr/bin/time'

This will overwrite the shell keyword time because the command:


type time

will give the following output now:


time is aliased to `/usr/bin/time'

[#26510] Friday, November 18, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
repend

Total Points: 195
Total Questions: 113
Total Answers: 107

Location: Nicaragua
Member since Tue, Dec 8, 2020
3 Years ago
repend questions
Thu, May 11, 23, 09:38, 1 Year ago
Thu, Jan 5, 23, 21:41, 1 Year ago
Mon, Nov 22, 21, 19:37, 2 Years ago
Mon, Jan 24, 22, 11:26, 2 Years ago
;