Shell/Bash: powershell for loop Example

By

Shell/Bash Example: This is the "powershell for loop" Example. compiled from many sources on the internet by SimpleTutorials.org

powershell for loop

> $array = @("item1", "item2", "item3")
 
> for($i = 0; $i -lt $array.length; $i++){ $array[$i] }
item1
item2
item3

powershell for each loop

> $array = @("item1", "item2", "item3")
 
> foreach ($element in $array) { $element }
item1
item2
item3
 
> $array | foreach { $_ }
item1
item2
item3



* Summary: This "powershell for loop" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others