aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/notes/easy-time-took-in-bash.md23
1 files changed, 23 insertions, 0 deletions
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 @@
1---
2title: "Easy meassure time took in a bash script"
3url: easy-time-took-in-bash.html
4date: 2023-05-28T17:53:20+02:00
5type: notes
6draft: false
7tags: [bash]
8---
9
10In 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.
11
12```bash
13#!/bin/bash
14
15# Reset the timer to zero.
16SECONDS=0
17
18# Do something.
19sleep 5
20
21# Print the time elapsed.
22echo "Time taken: $SECONDS seconds"
23```