$x = Get-Content test.txt
$x -replace "t","x" | Out-File new.txt
Get-Content is just reading in the text file as a big chunk o’ text.
ForEach ($line in (Get-Content test.txt)) {
$line -replace "\d","x" | Out-File new.txt -Append
}
$file = New-Object System.IO.StreamReader -Arg "test.txt"
while ($line = $file.ReadLine()) {
# $line has your line
}
$file.close()
Read full article from Why Get-Content Ain’t Yer Friend | PowerShell.org
$x -replace "t","x" | Out-File new.txt
Get-Content is just reading in the text file as a big chunk o’ text.
ForEach ($line in (Get-Content test.txt)) {
$line -replace "\d","x" | Out-File new.txt -Append
}
$file = New-Object System.IO.StreamReader -Arg "test.txt"
while ($line = $file.ReadLine()) {
# $line has your line
}
$file.close()
Read full article from Why Get-Content Ain’t Yer Friend | PowerShell.org
No comments:
Post a Comment