Skip to main content
added 157 characters in body
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script (where sh is not based on bash, ksh nor zsh) where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | time"time" bc ...

as it's really bc you want to get the execution time of here.

Quoting time here makes sure it's not treated as a keyword in shells that have a time keyword.

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | time bc ...

as it's really bc you want to get the execution time of here.

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script (where sh is not based on bash, ksh nor zsh) where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | "time" bc ...

as it's really bc you want to get the execution time of here.

Quoting time here makes sure it's not treated as a keyword in shells that have a time keyword.

edited body
Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | time bc ...

as it's really dcbc you want to get the execution time of here.

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | time bc ...

as it's really dc you want to get the execution time of here.

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | time bc ...

as it's really bc you want to get the execution time of here.

Source Link
Stéphane Chazelas
  • 586.9k
  • 96
  • 1.1k
  • 1.7k

I suspect your interactive shell is bash or zsh where time is a keyword.

And your script is a sh script where time is /usr/bin/time which would only time the echo command above.

Just do:

echo ... | time bc ...

as it's really dc you want to get the execution time of here.