Array is not storing data from text file as expected. How to get first word of each line into array using Powershell?
问题 Here is my code: Get-Content 'hist4.txt' | ForEach-Object { $_.split(" ")[0]} | ForEach-Object { $rgbArray += $_ for( $i = 1; $i -le $rgbArray.length; $i++ ) { $rgbA0=$rgbArray[$i] $rgbA1=$rgbArray[$i + 1] //compare A0 and A1... } } The text file contents: 1 500 21 456 33 789 40 653 54 900 63 1000 101 1203 I want to load the text file. Get-Content 'hist4.txt' It has two elements on each line. I need the first element. ForEach-Object { $_.split(" ")[0]} I need to store the first element of