This is simple but might be a bit more interesting.
If there is an elegant solution it will be very useful.
#!/bin/bash while IFS= read -r line do echo "running" done< <(sleep 10) exit
The code above starts the loop with a 10 second timeout after which the loop terminates.
Obviously since nothing is read, there is nio cycling and the echo is not executed.
Is there a way to make the while loop cycle and continuously print the echo using the sleep command with some other wizardry fed in to the loop as currently done. ?
Or to alter the IFS variable declaration in a way that can effect that ?
I was thinking along the lines to replace sleep 10 with timed random data as in the script. The random data will loop the while loop but it needs be terminated by the sleep 10.
Sort of a
}> >(sleep10–Randomdata something)
Cannot think of a way to make this work or if it is possible.
I dont need any of the data fed in to the loop. I only need the loop to cycle for 10 seconds.
This can be very useful for timed menu selections after a certain timeout (user is finished fidling) the current selection is made effective.
Fine, I can solve this if I can generate a script that outputs random data for a period of time and then save in /usr/bin and call it in place of Sleep 10 above, but it would noce to do this with built in commands.