Skip to main content
Quote
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

Here is how I would do it using bash special parameter SECONDS:

#!/bin/bash                                                                                                                                                                                  

SECONDS=0
# script is here                                                                                                                                                                             
sleep $"$(( 500 > SECONDS ? 500 - SECONDS : 1 ))"

Normally SECONDS returns time (in seconds) since the script has started, but one can assign any value to (re)set the timer.

Here is how I would do it using bash special parameter SECONDS:

#!/bin/bash                                                                                                                                                                                  

SECONDS=0
# script is here                                                                                                                                                                             
sleep $(( 500 > SECONDS ? 500 - SECONDS : 1 ))

Normally SECONDS returns time (in seconds) since the script has started, but one can assign any value to (re)set the timer.

Here is how I would do it using bash special parameter SECONDS:

#!/bin/bash                                                                                                                                                                                  

SECONDS=0
# script is here                                                                                                                                                                             
sleep "$(( 500 > SECONDS ? 500 - SECONDS : 1 ))"

Normally SECONDS returns time (in seconds) since the script has started, but one can assign any value to (re)set the timer.

Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

Here is how I would do it using bash special parameter SECONDS:

#!/bin/bash                                                                                                                                                                                  

SECONDS=0
# script is here                                                                                                                                                                             
sleep $(( 500 > SECONDS ? 500 - SECONDS : 1 ))

Normally SECONDS returns time (in seconds) since the script has started, but one can assign any value to (re)set the timer.