aboutsummaryrefslogtreecommitdiff
path: root/content/notes/easy-time-took-in-bash.md
blob: c97f0f10a8108dfdc82fa0e2bd535d500df1a0bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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"
```