LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   time command problems? (https://www.linuxquestions.org/questions/linux-newbie-8/time-command-problems-587049/)

WingnutOne 09-24-2007 02:37 PM

time command problems?
 
I'm running a BASH shell in RHE4 and can't get any of the time command's arguments (the man page calls them "options") to work. All of the options that I've tried giving it (except -p), however, are being treated by BASH as separate commands.
Example:
Code:

time -o filename date
generates the error message:
Code:

-bash: -o: command not found
The same thing happens with the long version:
Code:

time --output filename date
Per the man page, I'm using the right syntax.
time, without any options, runs just fine.

Has anyone else experienced similar problems? Am I misreading how it's supposed to work?

If it really is goofed up, is there another way to redirect the output? (It normally goes to standard error.)

Thanks!

matthewg42 09-24-2007 02:58 PM

Try using the full path of the command:
Code:

/usr/bin/time
"time" may be an internal command in your shell, a function or an alias.

indeliblestamp 09-24-2007 03:09 PM

Very weird, I'm facing the same problem too. It works if I put a leading '\', or use the full path though. Don't ask me how :)
Code:

arun ~ $ \time -o scrap date
Tue Sep 25 01:40:52 IST 2007
arun ~ $ cat scrap
        0:00.01,        0
arun ~ $ /usr/bin/time -o scrap date
Tue Sep 25 01:42:09 IST 2007
arun ~ $ cat scrap
        0:00.00,        0


WingnutOne 09-24-2007 03:11 PM

Quote:

Originally Posted by matthewg42 (Post 2902378)
Try using the full path of the command:
Code:

/usr/bin/time
"time" may be an internal command in your shell, a function or an alias.


:scratch: Now why didn't I think of that?
'cause I'm a :Pengy: :newbie:, that's why!

Thanks matthewg42, that took care of it!

...But now I'm even more curious about what it was that caused the change. I didn't find any reference to an alias for the time command in any of the usual places (/etc/bashrc, /root/.bashrc, or even in /etc/profile). An alias command didn't turn up anything either.
Where else is something like that likely to be found?

Berhanie 09-26-2007 10:05 PM

Quote:

Where else is something like that likely to be found?
As others have said, time is a bash builtin command. This is from the bash man page regarding how bash executes commands:
Code:

      If  the  command  name  contains  no  slashes,  the  shell
      attempts  to  locate it.  If there exists a shell function
      by that name, that function is invoked as described  above
      in  FUNCTIONS.  If the name does not match a function, the
      shell searches for it in the list of shell builtins.  If a
      match is found, that builtin is invoked.

      If the name is neither a shell function nor a builtin, and
      contains no slashes, bash searches  each  element  of  the
      PATH for a directory containing an executable file by that
      name...


WingnutOne 09-27-2007 09:52 AM

Sorry Berhanie. Don't know what I was thinking in that last paragraph; asking a question that I'd just finished thanking matthew for answering. :scratch:
Chock it up to a long day and not enough sleep I guess. :confused:

Thanks again!


All times are GMT -5. The time now is 07:12 PM.