linux run command in loop 1

linux run command in loop

// this is simple for loop with sleep

for i in {1..10}; do echo -n "This is a test in loop $i "; date ; sleep 2; done

Here is what the above code is Doing:
1. The for loop is iterating over the numbers 1 to 10.
2. The echo command is printing the text “This is a test in loop $i” where $i is the number of the current iteration.
3. The date command is printing the current date and time.
4. The sleep command is pausing the script for 2 seconds.
5. The semicolon (;) is used to separate the commands.

Similar Posts