Of the two C-shell aliases below, only the first prints the time command's report of elapsed time. How can I get the alias with the pipeline to also print the time report?
alias make1 'time make' alias make2 'time make |& tee make.log'
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
The time command built-in to the C shell (csh or tcsh) doesn't work with pipelines. To avoid this limitation, use the standalone time command instead, which is usually found at /usr/bin/time (if it isn't, try
whereis time to locate it).
time in your command-line to
/usr/bin/time -p) or whatever the path to the time program is, and it should work.
Why it didn't work:
The C shell (like some other shells) has a built-in time command (see the builtin manual page), which is used in preference to the non-builtin (standalone) time program:
% which time time: shell built-in command. %
and the man page for csh (actually tcsh on my system) states:
time [command] Executes command (which must be a simple command, not an alias, a pipeline, a command list or a parenthesized command list) ...
The /usr/bin/time command doesn't have this limitation, and neither do the inbuilt time commands of most other shells, for example bash or zsh.