2

I am attempting to achieve the effect of a batch file that does something similar to the following concept:

:start
ECHO 1
ECHO 2
ECHO 3
ECHO 4
ECHO 5
goto start

That is how I would make a batch file in Windows, but I am new to Linux, and would like to achieve a similar idea here in this operating system.

Eliah Kagan
  • 117,780

1 Answers1

3

In bash scripting you do not have gotos; you should use a while loop. For the while loop to run endlessly, you can use the true command which returns status of 0 (meaning successful run of a command).

So, you can create your "endless" loop like this:

while true ; do
  echo 1
  echo 2
  echo 3
  echo 4
  echo 5
done 
FedKad
  • 10,515