Greetings,
I have a file with:
Y21 M3_SWO JTAG_TDO/M3_TDO/M3_SWO Reserved
Y22 M3_TRSTB JTAG_TRSTB/M3_TRSTB Reserved
I have the following code to read the file then try to process
each element on the line:
$a = Get-Content -Path .\pin.txt
foreach ($line in $a) {
#$element = $line.Split(" ")
$element = $line -split "\s+"
Write-Host "E1: $element[0]"
}
However the .Split or -split doesn't work? I get:
E1: Y21 M3_SWO JTAG_TDO/M3_TDO/M3_SWO Reserved[0]
E1: Y22 M3_TRSTB JTAG_TRSTB/M3_TRSTB Reserved[0]
I've tied to convert to a string or pipe to Out-String on the reading, but that didn't work. Any idea what I'm doing wrong? Why is it not spliting the line variable into an array?
Thanks in advance for any help!
Tom
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (3 / 13) |
Uptime: | 56:03:09 |
Calls: | 6,652 |
Calls today: | 4 |
Files: | 12,200 |
Messages: | 5,330,863 |