PowerTip: Use PowerShell to Parse Delimiters in File

Doctor Scripto

Summary: Use Windows PowerShell to parse file delimiters in a file. Hey, Scripting Guy! Question How can I use Windows PowerShell to break out lines in a text file that are delimited by “\”? Here is the file content:

PS C:> Get-Content C:fsoAnEmptyFile.txt

This is content

\mydata\more stuff

\addmydata\addmore stuff\evenmore

Hey, Scripting Guy! Answer Use the –Delimiter parameter of the Get-Content cmdlet. Here is an example with the associated output:

PS C:> Get-Content C:fsoAnEmptyFile.txt -Delimiter \

This is content

\

mydata\

more stuff

\

addmydata\

addmore stuff\

evenmore

0 comments

Discussion is closed.

Feedback usabilla icon