Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-NewLine Parameter to customize line separator for Get-Content #14647

Closed
iRon7 opened this issue Jan 21, 2021 · 2 comments
Closed

-NewLine Parameter to customize line separator for Get-Content #14647

iRon7 opened this issue Jan 21, 2021 · 2 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug

Comments

@iRon7
Copy link

iRon7 commented Jan 21, 2021

By default Get-Content (and switch -File) streams lines on either CR, CRLF, or LF newlines, which is a good thing as it allows to interchange (large) text files between Operating Systems. The point is though that in some cases a more specific line terminator is required (e.g. only a CRLF) which could possible lead to not being able to stream lines (using standard cmdlets to prevent out of memory exceptions) if it concerns very large text files.
See: StackOverflow Powershell - Count number of carriage returns line feed in .txt file

An additional Parameter as -Newline <string> (e.g. -Newline "`r`n") could resolve this and might also allow to stream a (large) text file on a completely different character (combination) as e.g. a tab: -Newline "`t".

Related

@iRon7 iRon7 added the Issue-Enhancement the issue is more of a feature request than a bug label Jan 21, 2021
@mklement0
Copy link
Contributor

mklement0 commented Jan 21, 2021

Note that Get-Content already has a -Delimiter parameter that serves this purpose: it accepts any literal string as the string to split the file content by, using terminator logic rather than separator logic (that is, if the content ends in the given string, no additional, empty element is reported).

-Delimiter is a dynamic parameter of the FileSystem provider.

@iRon7
Copy link
Author

iRon7 commented Jan 21, 2021

I completely missed this -Delimiter parameter

@iRon7 iRon7 closed this as completed Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug
Projects
None yet
Development

No branches or pull requests

2 participants