Reputation: 2195
I have got a file txt which contains music lyrics.
I want to replace all dots by a carriage return to have something more readable.
Thanks in advance.
Upvotes: 2
Views: 8274
Reputation: 52587
Easy enough:
Get-Content C:\Imagine_Lyrics.txt | % {$_.Replace('.', "`n")} | Out-File C:\Imagine_Lyrics2.txt -Encoding ASCII
Upvotes: 2
Reputation: 68273
(get-content file.txt) -replace '\.',"`n" | out-file newfile.txt
The -replace operater uses a regex match, so you need to escape the dot to make it match a literal dot. Otherwise it will replace every character in the file.
Upvotes: 4