添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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 ~]$