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 have to run a couple of command lines on a shell script on Ubuntu, one of those is a pi calculation.

It works fine when i run it on terminal via the following cmd line:

time echo "scale=6500;4*a(1)" | bc -l

But when I run it on a script I get no luck. Typing in time before I execute the script i.e.

time ./filename.sh

isn't enough as I have to also run other commands in the script.

Any suggestions?

share|improve this question
1  
Define “no luck”. In meantime see if How to get execution time of a script effectively? has anything useful for you. –  manatwork Oct 29 '12 at 9:37
add comment

1 Answer

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.

share|improve this answer
add comment

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.