Question:
I need to read the first line of a file and then the subsequent lines I want read using a loop.
eg:
1 2 3 4 5 6 7 8 |
Read in first line Do stuff with the data foreach ($line in $remainingLines) { more stuff } |
I have a rather messy way to achieve this but there must be a better way.
Answer:
Assign the content of the file to two variables. The first one will hold the first line, and the second variable gets the rest. Then loop over $remainingLines.
1 2 |
$firstLine,$remainingLines = Get-Content foo.txt |