From cd6644ea4ddc78597934ab0ef5ba50e3c3daa927 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sat, 8 Jul 2023 23:25:41 +0200 Subject: Moved to a simpler SSG --- content/easy-time-took-in-bash.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 content/easy-time-took-in-bash.md (limited to 'content/easy-time-took-in-bash.md') diff --git a/content/easy-time-took-in-bash.md b/content/easy-time-took-in-bash.md new file mode 100644 index 0000000..999434a --- /dev/null +++ b/content/easy-time-took-in-bash.md @@ -0,0 +1,25 @@ +--- +title: "Easy measure time took in a bash script" +url: easy-time-took-in-bash.html +date: 2023-05-28T17:53:20+02:00 +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