Hi powershell,
$input = (Get-Content H:\aa.txt| ForEach-Object{ $_.Trim()} | ForEach-Object {($_ -replace '\s+',',')})
foreach($line in $input){
$element = $line -split ','
[array]$index = $element[4]
$index = "55"
Write-Output "$line,$index"
}
Where aa.txt:
aa bb cc
dd ee ff
gg hh ii
11 22 33
44 55 66
The output:
aa,bb,cc,55
dd,ee,ff,55
gg,hh,ii,55
11,22,33,55
44,55,66,55
How to add anoher new insert column?
e.g if [array]$index = $element[6]
then output should display like this:
aa,bb,cc,,,55
dd,ee,ff,,,55
gg,hh,ii,,,55
11,22,33,,,55
44,55,66,,,55
Any Idea?
Thanks