-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Bash Cookbook
By :

In this recipe, we are going to learn how to calculate and reduce the script’s runtime. A simple time
command will help in calculating the execution time.
Besides having a terminal open, make sure you have the necessary scripts present in your system.
Now, we will write a simple script that contains a few commands, and then, using the time
command, we will get the runtime of that script. Create a script cal_runtime.sh
and write the following code in it.
clear ls -l date sudo apt install python3
Now, we have written a script cal_runtime.sh
and four commands in that script: clear, ls, date,
and a python3
installation command. Run your script as follows:
$ time bash cal_runtime.sh
After the execution, you will get the runtime of the script at the bottom of your output.