I have a text-file that contains a bunch of data on a single line without any line-breaks . It will contain data that looks similar to this:
{"Id":1801157,":"33611134":"E","Oct 19:":"G","Order":"117" ,"BroadcastDate":"2019-10-19"}
What I want to do is insert a line break right before BroadcastDate
so it now looks like this:
{"Id":1801157,":"33611134":"E","Oct 19:":"G","Order":"117" ,"
BroadcastDate":"2019-10-19"}
I want to be able to do it via a the windows command-line . So basically I want do to find BroadcastDate
and replace it with <line break>BroadcastDate
.
Seems like an odd thing to do, but not very difficult in PowerShell. If you are on a supported Windows system, it will have PowerShell.
=== Format-BroadcastFile.ps1
Get-Content -Path '.\BroadcastDate.txt' |
ForEach-Object {
$_ -replace 'BroadcastDate'."`nBroadcastDate"
}
=== Run it in a.bat file script or the cmd shell.
powershell -NoLogo -NoProfile -File "Format-BroadcastFile.ps1" >".\newfile.txt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.