From 2417a6b7603524dc5cd30d29b153f91024b9443d Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 1 Nov 2023 22:54:27 +0100 Subject: Move to Jekyll --- _posts/2023-05-28-easy-time-took-in-bash.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 _posts/2023-05-28-easy-time-took-in-bash.md (limited to '_posts/2023-05-28-easy-time-took-in-bash.md') diff --git a/_posts/2023-05-28-easy-time-took-in-bash.md b/_posts/2023-05-28-easy-time-took-in-bash.md new file mode 100644 index 0000000..958da72 --- /dev/null +++ b/_posts/2023-05-28-easy-time-took-in-bash.md @@ -0,0 +1,26 @@ +--- +title: "Easy measure time took in a bash script" +permalink: /easy-time-took-in-bash.html +date: 2023-05-28T17:53:20+02:00 +layout: post +type: note +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