Simple for loop in bash

First, I wanted to try to create a for loop in bash :

#!/bin/bash

for i in `seq 1 3`;
do
  echo "hello world"
done

To execute this simple script, we need to save it as a .sh file, and make it executable :

nano script.sh

chmod +x script.sh

Then, we can start it :

./script.sh

hello world

hello world

hello world

hello world

Leave a Reply

Your email address will not be published.