Link Search Menu Expand Document

Loop

#! /bin/bash
echo "some lines of code here"

for i in {1..4}
do 
    echo "hello, this is number $i"
done 

echo "* ------------------ * "

for i in {1,"anystring",-5,"hello","something",4}
# no space between strings inside { ... }
do 
    echo "hello, for i the varible is: $i"
done 

echo "* ------------------ * "

for i in {1,"anystring",-5,"hello","something",4}
do 
    echo "hello, for i the varible is: $i"
    if [ $i == "hello" ]; then 
        echo " We are done here"
        break
    fi
done 

echo "* -------- Loop all the files in the directory ---------- * "

for i in ./*
do 
    echo "name of the file is: $i"
done