Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I installed ZSH (and Oh-My-ZSH) on a Ubuntu 12.10 64 bit machine a few days ago. I just tried to do:

time (time ls)

and got this error:

zsh: command not found: time
( time ls; )  0.00s user 0.00s system 64% cpu 0.002 total

The exact same thing works on ZSH on my Mac.

I also tried running ZSH without loading any config file, using zsh -f -d, but got the same error.

What could be the problem here?


Some more output that may help:

➜  ~  type -a time
time is a reserved word
➜  ~  time (type -a time)
time is a reserved word
( type -a time; )  0.00s user 0.00s system 0% cpu 0.001 total
➜  ~  time (time)
zsh: command not found: time
( time; )  0.00s user 0.00s system 0% cpu 0.001 total
➜  ~  which time
time: shell reserved word
➜  ~  time (which time)
time: shell reserved word
( which time; )  0.00s user 0.00s system 0% cpu 0.001 total
share|improve this question

migrated from serverfault.com May 21 '13 at 23:54

This question came from our site for professional system and network administrators.

    
A simple bit googleing (googling?) yielded this bug report: bugs.debian.org/cgi-bin/bugreport.cgi?bug=41644 –  Tim Lamballais May 21 '13 at 12:08
    
@TimLamballais, that seems to be fixed in 3.1.5, I'm on 5.0.0 (zsh 5.0.0 (x86_64-unknown-linux-gnu)) –  Dogbert May 21 '13 at 12:09
    
Ah I see now. What exactly are you trying to accomplish? In your examples I don't see any reason not to run time as your first command? –  Tim Lamballais May 21 '13 at 12:16
    
Anyway, does it help if you substitute time form /usr/bin/time (or wherever your binary is located? –  Tim Lamballais May 21 '13 at 12:25
    
@TimLamballais, I want to do something like time (ls | while read line; do; time ls $line; done;). There was no time executable on the system, so I did apt-get install time, now I have /usr/bin/time, which seems to work if I use the full path. –  Dogbert May 21 '13 at 12:40

1 Answer 1

time is a reserved word in zsh. It is only recognized at the beginning of a command. It's a reserved word, and not a builtin, because when you write time foo | bar, it is the compound command foo | bar that is timed and not just foo.

Where time isn't recognized as a reserved word, it's interpreted as the name of an external command. Your system, for whatever reason, has no time command installed. So commands like \time, =time, or the second time in time time try to invoke the non-existent time executable and you get the error message “command not found: time”.

If you want to be able to run time (time ls) (not that this is a useful command), install the time package. It's a dependency of ubuntu-standard, which is a sign that you should have it installed.

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.