Quantcast
Channel: Increment a variable timely in bash script - Unix & Linux Stack Exchange
Browsing all 4 articles
Browse latest View live

Answer by Praveen Kumar BS for Increment a variable timely in bash script

Below is code i=10 for ((j=1;j<=count_of_sequence;j++)); do echo $i; sleep 10;i=$(($i+1)); done output 10 11 12 13 14

View Article



Answer by markgraf for Increment a variable timely in bash script

A horrible solution: #!/bin/bash somevar=0 somefile=$(mktemp) echo "$somevar" > "$somefile" while true; do sleep 3; ((somevar++)); echo "$somevar" > "$somefile" ;done & while true; do sleep 1...

View Article

Answer by Stéphane Chazelas for Increment a variable timely in bash script

In bash, the $SECONDS special variable is already incremented once every second like in ksh where the feature comes from. It's initialised to 0 at the time the shell starts (or from the value of the...

View Article

Increment a variable timely in bash script

I want to increment a variable by one every 3 seconds. Is there any way to do that using bash? I had a program running in infinite loop in which I am doing some stuff with a variable; I want to...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images