From 048c9b2a7d0ddf252667fa7cfff87cbf4acfd48a Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sun, 28 May 2023 17:57:46 +0200 Subject: Note: Measure time took --- content/notes/easy-time-took-in-bash.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 content/notes/easy-time-took-in-bash.md (limited to 'content') diff --git a/content/notes/easy-time-took-in-bash.md b/content/notes/easy-time-took-in-bash.md new file mode 100644 index 0000000..c97f0f1 --- /dev/null +++ b/content/notes/easy-time-took-in-bash.md @@ -0,0 +1,23 @@ +--- +title: "Easy meassure time took in a bash script" +url: easy-time-took-in-bash.html +date: 2023-05-28T17:53:20+02:00 +type: notes +draft: false +tags: [bash] +--- + +In Bash, the $SECONDS variable is a special variable that automatically keeps track of the number of seconds since the current shell or script started executing. It starts counting from the moment the script begins running. + +```bash +#!/bin/bash + +# Reset the timer to zero. +SECONDS=0 + +# Do something. +sleep 5 + +# Print the time elapsed. +echo "Time taken: $SECONDS seconds" +``` -- cgit v1.2.3