Forrest logo
back to the while tool

while:tldr:c7dcb

while: Execute a command forever once every second.
$ while :; do ${command}; sleep 1; done
try on your machine

This command is a basic shell script construct using the "while" loop in Unix-like operating systems. Let's break it down step by step:

  1. while :; - This is the start of the while loop. The : is a shorthand way of representing the true condition. Essentially, it continuously evaluates to true, creating an infinite loop.

  2. do - This keyword signifies the beginning of the loop body, which contains the commands to be executed repeatedly.

  3. ${command} - This is a placeholder for the actual command that you want to execute repeatedly. You would replace ${command} with your desired command. For example, if you want to execute the ls command repeatedly, you would use while :; do ls; sleep 1; done.

  4. sleep 1 - This command introduces a 1-second delay before the next iteration of the loop. It pauses the execution for the specified time duration. In this case, it waits for 1 second before executing the loop again.

  5. done - This indicates the end of the loop body. After the done keyword, the loop goes back to the beginning and repeats the process until interrupted.

So, the overall functionality of the command is to execute the given command repeatedly in an infinite loop with a 1-second delay between each iteration.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the while tool