In bash there is no foreach , so we can use “ for ” instead

[j@localhost ~]$ for x in a b c 1 2 3;do echo $x;done

Or if need to iterate from a file

[j@localhost ~]$ for x in `cat file.txt`;do echo "Here is $x";done
Here is 1stline
Here is 2ndline
Here is 3rdline

Or we can also use “while” to iterate from file

[j@localhost ~]$ while read file
> echo "Here is $file"
> done < file.txt
Here is 1stline
Here is 2ndline
Here is 3rdline
[j@localhost ~]$