Score:-2

time command do not work for my shell script

cn flag

I try to measure the time of my shell script (I normally run it with ./my-script) with time linux command like this:

time my-script

but I receive the following error

-bash: my-script: command not found

This approach I took it from here https://unix.stackexchange.com/a/314382, but it doesn't work. Does anyone know why?

pl flag
Use the full path? `/usr/bin/time /path/to/my-script` to be sure.
thezbx avatar
cn flag
it worked with the full path to my-script. thank you!!!!!
Score:3
in flag

If you normally run the script as ./my-script, then you should run it with time using time ./my-script as well.

The reason is that time doesn't change the way your PATH is searched and you need to give a path name (relative or absolute), rather than just a naked command to run, since the current directory is typically not in your PATH.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.