Answer the question
In order to leave comments, you need to log in
How to substitute characters in a file for strings and return them to another file in Powershell?
Hello.
It is necessary to take the data from one file. Substitute characters at the beginning and end of lines of text and return the finished data to another file.
Wrote like this, but only one last line is returned:
$file = Get-Content "C:\Temp\result.txt"
$pp = "PP"
$pp111 = "pp111"
foreach ($line in $file) {
"$pp$line$pp111" | Out-File -FilePath C:\Temp\re.txt -Encoding oem
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question