Example 1
#!/bin/bash
for i in 1 2 3 4 5
do
echo "Hello $i times"
done
Example 2
#!/bin/bash
for i in eat run jump play
do
echo "See Dmitri $i"
done
Example 3
#!/bin/bash
for i in {1..5}
do
touch $i
done
Example 4
#!/bin/bash
i=1
for day in Mon Tue Wed Thu Fri Sat Sun
do
echo "Weekday $((i++)) is $day"
done
Example 5
#!/bin/bash
i=1
for username in `awk -F: '{print $1}' /etc/passwd`
do
echo "Username $((i++)) is $username"
done
Example 6
#!/bin/bash
echo How many files you want
read total
echo Enter the start name of the file
read n
for i in $(seq 1 $total)
do
touch $n.$i
done
Example 7
#!/bin/bash
for i in file.*
do
echo Assigning write permissions to $i
chmod a+w $i
sleep 1
done